From 639b256351d910e7c551212cbe7a7649726c0db9 Mon Sep 17 00:00:00 2001 From: Rubesh S Date: Tue, 17 Oct 2023 20:31:17 +0800 Subject: [PATCH 1/5] Refactor seedu.address package to unicash --- build.gradle | 4 +- docs/SettingUp.md | 2 +- docs/Testing.md | 9 +- .../parser/AddTransactionCommandParser.java | 76 ------------ .../address => unicash}/AppParameters.java | 8 +- .../java/{seedu/address => unicash}/Main.java | 4 +- .../{seedu/address => unicash}/MainApp.java | 48 ++++---- .../commons/core/Config.java | 4 +- .../commons/core/GuiSettings.java | 4 +- .../commons/core/LogsCenter.java | 2 +- .../commons/core/Version.java | 2 +- .../commons/core/index/Index.java | 4 +- .../commons/enums/TransactionType.java | 2 +- .../exceptions/DataLoadingException.java | 2 +- .../exceptions/IllegalValueException.java | 2 +- .../commons/util/AppUtil.java | 4 +- .../commons/util/CollectionUtil.java | 2 +- .../commons/util/ConfigUtil.java | 6 +- .../commons/util/FileUtil.java | 2 +- .../commons/util/JsonUtil.java | 6 +- .../commons/util/StringUtil.java | 4 +- .../commons/util/ToStringBuilder.java | 2 +- .../address => unicash}/logic/Logic.java | 12 +- .../logic/LogicManager.java | 22 ++-- .../logic/UniCashMessages.java | 6 +- .../logic/commands/AddTransactionCommand.java | 43 +++---- .../commands/ClearTransactionsCommand.java | 6 +- .../logic/commands/Command.java | 6 +- .../logic/commands/CommandResult.java | 4 +- .../commands/DeleteTransactionCommand.java | 14 +-- .../commands/EditTransactionCommand.java | 42 +++---- .../logic/commands/ExitCommandUniCash.java | 4 +- .../logic/commands/FindCommand.java | 10 +- .../commands/GetTotalExpenditureCommand.java | 16 +-- .../logic/commands/HelpCommandUniCash.java | 4 +- .../logic/commands/ListCommand.java | 7 +- .../commands/exceptions/CommandException.java | 2 +- .../parser/AddTransactionCommandParser.java | 69 +++++++++++ .../logic/parser/AddressBookParser.java | 30 ++--- .../logic/parser/ArgumentMultimap.java | 6 +- .../logic/parser/ArgumentTokenizer.java | 2 +- .../logic/parser/CliSyntax.java | 2 +- .../DeleteTransactionCommandParser.java | 13 +- .../parser/EditTransactionCommandParser.java | 50 ++++---- .../logic/parser/FindCommandParser.java | 10 +- .../GetTotalExpenditureCommandParser.java | 20 ++-- .../logic/parser/ListCommandParser.java | 6 +- .../logic/parser/Parser.java | 6 +- .../logic/parser/ParserUtil.java | 20 ++-- .../logic/parser/Prefix.java | 2 +- .../parser/exceptions/ParseException.java | 4 +- .../address => unicash}/model/Model.java | 6 +- .../model/ModelManager.java | 15 +-- .../model/ReadOnlyUniCash.java | 4 +- .../model/ReadOnlyUserPrefs.java | 4 +- .../address => unicash}/model/UniCash.java | 8 +- .../address => unicash}/model/UserPrefs.java | 4 +- .../model/category/Category.java | 8 +- .../model/transaction/Amount.java | 8 +- .../model/transaction/DateTime.java | 15 ++- .../model/transaction/Location.java | 8 +- .../model/transaction/Name.java | 8 +- .../model/transaction/Transaction.java | 11 +- .../model/transaction/TransactionList.java | 11 +- ...nsactionNameContainsKeywordsPredicate.java | 6 +- .../model/transaction/Type.java | 9 +- .../TransactionNotFoundException.java | 2 +- .../model/util/SampleDataUtil.java | 20 ++-- .../storage/JsonAdaptedCategory.java | 6 +- .../storage/JsonAdaptedTransaction.java | 18 +-- .../storage/JsonSerializableUniCash.java | 10 +- .../storage/JsonUniCashStorage.java | 14 +-- .../storage/JsonUserPrefsStorage.java | 10 +- .../address => unicash}/storage/Storage.java | 10 +- .../storage/StorageManager.java | 12 +- .../storage/UniCashStorage.java | 11 +- .../storage/UserPrefsStorage.java | 12 +- .../address => unicash}/ui/CommandBox.java | 11 +- .../address => unicash}/ui/HelpWindow.java | 4 +- .../address => unicash}/ui/MainWindow.java | 16 +-- .../address => unicash}/ui/ResultDisplay.java | 2 +- .../ui/StatusBarFooter.java | 2 +- .../ui/TransactionCard.java | 4 +- .../ui/TransactionListPanel.java | 6 +- .../{seedu/address => unicash}/ui/Ui.java | 2 +- .../address => unicash}/ui/UiManager.java | 10 +- .../{seedu/address => unicash}/ui/UiPart.java | 4 +- .../commands/ExitCommandUniCashTest.java | 25 ---- .../model/transaction/TransactionTest.java | 85 ------------- .../address/testutil/TransactionUtil.java | 68 ----------- .../address/testutil/TypicalTransactions.java | 89 -------------- .../AppParametersTest.java | 2 +- .../commons/core/ConfigTest.java | 2 +- .../commons/core/GuiSettingsTest.java | 2 +- .../commons/core/VersionTest.java | 7 +- .../commons/core/index/IndexTest.java | 9 +- .../commons/util/AppUtilTest.java | 11 +- .../commons/util/CollectionUtilTest.java | 15 +-- .../commons/util/ConfigUtilTest.java | 17 +-- .../commons/util/FileUtilTest.java | 7 +- .../commons/util/JsonUtilTest.java | 6 +- .../commons/util/StringUtilTest.java | 15 +-- .../logic/LogicManagerTest.java | 69 +++++------ .../logic/UniCashMessagesTest.java | 4 +- .../commands/AddCommandIntegrationTest.java | 14 +-- .../commands/AddTransactionCommandTest.java | 29 ++--- .../ClearTransactionsCommandTest.java | 20 ++-- .../logic/commands/CommandResultTest.java | 2 +- .../logic/commands/CommandTestUtil.java | 66 +++++----- .../DeleteTransactionCommandTest.java | 59 +++++---- .../commands/EditPersonDescriptorTest.java | 14 +-- .../commands/EditTransactionCommandTest.java | 111 ++++++++--------- .../commands/ExitCommandUniCashTest.java | 24 ++++ .../logic/commands/FindCommandTest.java | 16 +-- .../GetTotalExpenditureCommandTest.java | 36 +++--- .../commands/HelpCommandUniCashTest.java | 10 +- .../logic/commands/ListCommandTest.java | 14 +-- .../AddTransactionCommandParserTest.java | 113 +++++++++--------- .../logic/parser/AddressBookParserTest.java | 53 ++++---- .../logic/parser/ArgumentTokenizerTest.java | 2 +- .../logic/parser/CommandParserTestUtil.java | 11 +- .../DeleteTransactionCommandParserTest.java | 8 +- .../EditTransactionCommandParserTest.java | 113 +++++++++--------- .../logic/parser/FindCommandParserTest.java | 16 ++- .../GetTotalExpenditureCommandParserTest.java | 8 +- .../logic/parser/ListCommandParserTest.java | 6 +- .../logic/parser/ParserUtilTest.java | 75 ++++++------ .../model/ModelManagerTest.java | 41 +++---- .../model/UniCashTest.java | 22 ++-- .../model/UserPrefsTest.java | 11 +- .../model/category/CategoryTest.java | 4 +- .../model/transaction/AmountTest.java | 7 +- .../model/transaction/DateTimeTest.java | 11 +- .../model/transaction/LocationTest.java | 9 +- .../model/transaction/NameTest.java | 11 +- .../transaction/TransactionListTest.java | 14 +-- ...tionNameContainsKeywordsPredicateTest.java | 4 +- .../model/transaction/TransactionTest.java | 84 +++++++++++++ .../model/transaction/TypeTest.java | 9 +- .../storage/JsonAdaptedTransactionTest.java | 48 ++++---- .../storage/JsonSerializableUniCashTest.java | 14 +-- .../storage/JsonUniCashStorageTest.java | 16 +-- .../storage/JsonUserPrefsStorageTest.java | 19 +-- .../storage/StorageManagerTest.java | 13 +- .../address => unicash}/testutil/Assert.java | 2 +- .../EditTransactionDescriptorBuilder.java | 18 +-- .../testutil/SerializableTestClass.java | 2 +- .../testutil/TestUtil.java | 8 +- .../testutil/TransactionBuilder.java | 18 +-- .../unicash/testutil/TransactionUtil.java | 61 ++++++++++ .../testutil/TypicalIndexes.java | 4 +- .../unicash/testutil/TypicalTransactions.java | 73 +++++++++++ .../testutil/UniCashBuilder.java | 6 +- .../ui/TestFxmlObject.java | 2 +- .../address => unicash}/ui/UiPartTest.java | 31 ++--- .../resources/view/UiPartTest/validFile.fxml | 2 +- .../view/UiPartTest/validFileWithFxRoot.fxml | 4 +- 157 files changed, 1367 insertions(+), 1402 deletions(-) delete mode 100644 src/main/java/seedu/address/logic/parser/AddTransactionCommandParser.java rename src/main/java/{seedu/address => unicash}/AppParameters.java (92%) rename src/main/java/{seedu/address => unicash}/Main.java (96%) rename src/main/java/{seedu/address => unicash}/MainApp.java (86%) rename src/main/java/{seedu/address => unicash}/commons/core/Config.java (94%) rename src/main/java/{seedu/address => unicash}/commons/core/GuiSettings.java (96%) rename src/main/java/{seedu/address => unicash}/commons/core/LogsCenter.java (99%) rename src/main/java/{seedu/address => unicash}/commons/core/Version.java (98%) rename src/main/java/{seedu/address => unicash}/commons/core/index/Index.java (95%) rename src/main/java/{seedu/address => unicash}/commons/enums/TransactionType.java (98%) rename src/main/java/{seedu/address => unicash}/commons/exceptions/DataLoadingException.java (82%) rename src/main/java/{seedu/address => unicash}/commons/exceptions/IllegalValueException.java (93%) rename src/main/java/{seedu/address => unicash}/commons/util/AppUtil.java (94%) rename src/main/java/{seedu/address => unicash}/commons/util/CollectionUtil.java (96%) rename src/main/java/{seedu/address => unicash}/commons/util/ConfigUtil.java (78%) rename src/main/java/{seedu/address => unicash}/commons/util/FileUtil.java (98%) rename src/main/java/{seedu/address => unicash}/commons/util/JsonUtil.java (97%) rename src/main/java/{seedu/address => unicash}/commons/util/StringUtil.java (96%) rename src/main/java/{seedu/address => unicash}/commons/util/ToStringBuilder.java (97%) rename src/main/java/{seedu/address => unicash}/logic/Logic.java (76%) rename src/main/java/{seedu/address => unicash}/logic/LogicManager.java (81%) rename src/main/java/{seedu/address => unicash}/logic/UniCashMessages.java (94%) rename src/main/java/{seedu/address => unicash}/logic/commands/AddTransactionCommand.java (56%) rename src/main/java/{seedu/address => unicash}/logic/commands/ClearTransactionsCommand.java (82%) rename src/main/java/{seedu/address => unicash}/logic/commands/Command.java (78%) rename src/main/java/{seedu/address => unicash}/logic/commands/CommandResult.java (95%) rename src/main/java/{seedu/address => unicash}/logic/commands/DeleteTransactionCommand.java (86%) rename src/main/java/{seedu/address => unicash}/logic/commands/EditTransactionCommand.java (89%) rename src/main/java/{seedu/address => unicash}/logic/commands/ExitCommandUniCash.java (84%) rename src/main/java/{seedu/address => unicash}/logic/commands/FindCommand.java (87%) rename src/main/java/{seedu/address => unicash}/logic/commands/GetTotalExpenditureCommand.java (88%) rename src/main/java/{seedu/address => unicash}/logic/commands/HelpCommandUniCash.java (88%) rename src/main/java/{seedu/address => unicash}/logic/commands/ListCommand.java (82%) rename src/main/java/{seedu/address => unicash}/logic/commands/exceptions/CommandException.java (89%) create mode 100644 src/main/java/unicash/logic/parser/AddTransactionCommandParser.java rename src/main/java/{seedu/address => unicash}/logic/parser/AddressBookParser.java (75%) rename src/main/java/{seedu/address => unicash}/logic/parser/ArgumentMultimap.java (95%) rename src/main/java/{seedu/address => unicash}/logic/parser/ArgumentTokenizer.java (99%) rename src/main/java/{seedu/address => unicash}/logic/parser/CliSyntax.java (95%) rename src/main/java/{seedu/address => unicash}/logic/parser/DeleteTransactionCommandParser.java (65%) rename src/main/java/{seedu/address => unicash}/logic/parser/EditTransactionCommandParser.java (62%) rename src/main/java/{seedu/address => unicash}/logic/parser/FindCommandParser.java (73%) rename src/main/java/{seedu/address => unicash}/logic/parser/GetTotalExpenditureCommandParser.java (58%) rename src/main/java/{seedu/address => unicash}/logic/parser/ListCommandParser.java (81%) rename src/main/java/{seedu/address => unicash}/logic/parser/Parser.java (72%) rename src/main/java/{seedu/address => unicash}/logic/parser/ParserUtil.java (91%) rename src/main/java/{seedu/address => unicash}/logic/parser/Prefix.java (95%) rename src/main/java/{seedu/address => unicash}/logic/parser/exceptions/ParseException.java (73%) rename src/main/java/{seedu/address => unicash}/model/Model.java (94%) rename src/main/java/{seedu/address => unicash}/model/ModelManager.java (91%) rename src/main/java/{seedu/address => unicash}/model/ReadOnlyUniCash.java (76%) rename src/main/java/{seedu/address => unicash}/model/ReadOnlyUserPrefs.java (70%) rename src/main/java/{seedu/address => unicash}/model/UniCash.java (94%) rename src/main/java/{seedu/address => unicash}/model/UserPrefs.java (96%) rename src/main/java/{seedu/address => unicash}/model/category/Category.java (87%) rename src/main/java/{seedu/address => unicash}/model/transaction/Amount.java (82%) rename src/main/java/{seedu/address => unicash}/model/transaction/DateTime.java (88%) rename src/main/java/{seedu/address => unicash}/model/transaction/Location.java (88%) rename src/main/java/{seedu/address => unicash}/model/transaction/Name.java (87%) rename src/main/java/{seedu/address => unicash}/model/transaction/Transaction.java (89%) rename src/main/java/{seedu/address => unicash}/model/transaction/TransactionList.java (90%) rename src/main/java/{seedu/address => unicash}/model/transaction/TransactionNameContainsKeywordsPredicate.java (90%) rename src/main/java/{seedu/address => unicash}/model/transaction/Type.java (82%) rename src/main/java/{seedu/address => unicash}/model/transaction/exceptions/TransactionNotFoundException.java (75%) rename src/main/java/{seedu/address => unicash}/model/util/SampleDataUtil.java (77%) rename src/main/java/{seedu/address => unicash}/storage/JsonAdaptedCategory.java (89%) rename src/main/java/{seedu/address => unicash}/storage/JsonAdaptedTransaction.java (90%) rename src/main/java/{seedu/address => unicash}/storage/JsonSerializableUniCash.java (90%) rename src/main/java/{seedu/address => unicash}/storage/JsonUniCashStorage.java (86%) rename src/main/java/{seedu/address => unicash}/storage/JsonUserPrefsStorage.java (83%) rename src/main/java/{seedu/address => unicash}/storage/Storage.java (72%) rename src/main/java/{seedu/address => unicash}/storage/StorageManager.java (89%) rename src/main/java/{seedu/address => unicash}/storage/UniCashStorage.java (78%) rename src/main/java/{seedu/address => unicash}/storage/UserPrefsStorage.java (69%) rename src/main/java/{seedu/address => unicash}/ui/CommandBox.java (89%) rename src/main/java/{seedu/address => unicash}/ui/HelpWindow.java (97%) rename src/main/java/{seedu/address => unicash}/ui/MainWindow.java (93%) rename src/main/java/{seedu/address => unicash}/ui/ResultDisplay.java (95%) rename src/main/java/{seedu/address => unicash}/ui/StatusBarFooter.java (96%) rename src/main/java/{seedu/address => unicash}/ui/TransactionCard.java (94%) rename src/main/java/{seedu/address => unicash}/ui/TransactionListPanel.java (92%) rename src/main/java/{seedu/address => unicash}/ui/Ui.java (86%) rename src/main/java/{seedu/address => unicash}/ui/UiManager.java (94%) rename src/main/java/{seedu/address => unicash}/ui/UiPart.java (97%) delete mode 100644 src/test/java/seedu/address/logic/commands/ExitCommandUniCashTest.java delete mode 100644 src/test/java/seedu/address/model/transaction/TransactionTest.java delete mode 100644 src/test/java/seedu/address/testutil/TransactionUtil.java delete mode 100644 src/test/java/seedu/address/testutil/TypicalTransactions.java rename src/test/java/{seedu/address => unicash}/AppParametersTest.java (99%) rename src/test/java/{seedu/address => unicash}/commons/core/ConfigTest.java (97%) rename src/test/java/{seedu/address => unicash}/commons/core/GuiSettingsTest.java (98%) rename src/test/java/{seedu/address => unicash}/commons/core/VersionTest.java (96%) rename src/test/java/{seedu/address => unicash}/commons/core/index/IndexTest.java (87%) rename src/test/java/{seedu/address => unicash}/commons/util/AppUtilTest.java (63%) rename src/test/java/{seedu/address => unicash}/commons/util/CollectionUtilTest.java (89%) rename src/test/java/{seedu/address => unicash}/commons/util/ConfigUtilTest.java (85%) rename src/test/java/{seedu/address => unicash}/commons/util/FileUtilTest.java (82%) rename src/test/java/{seedu/address => unicash}/commons/util/JsonUtilTest.java (92%) rename src/test/java/{seedu/address => unicash}/commons/util/StringUtilTest.java (88%) rename src/test/java/{seedu/address => unicash}/logic/LogicManagerTest.java (76%) rename src/test/java/{seedu/address => unicash}/logic/UniCashMessagesTest.java (94%) rename src/test/java/{seedu/address => unicash}/logic/commands/AddCommandIntegrationTest.java (78%) rename src/test/java/{seedu/address => unicash}/logic/commands/AddTransactionCommandTest.java (91%) rename src/test/java/{seedu/address => unicash}/logic/commands/ClearTransactionsCommandTest.java (51%) rename src/test/java/{seedu/address => unicash}/logic/commands/CommandResultTest.java (98%) rename src/test/java/{seedu/address => unicash}/logic/commands/CommandTestUtil.java (68%) rename src/test/java/{seedu/address => unicash}/logic/commands/DeleteTransactionCommandTest.java (63%) rename src/test/java/{seedu/address => unicash}/logic/commands/EditPersonDescriptorTest.java (83%) rename src/test/java/{seedu/address => unicash}/logic/commands/EditTransactionCommandTest.java (60%) create mode 100644 src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java rename src/test/java/{seedu/address => unicash}/logic/commands/FindCommandTest.java (87%) rename src/test/java/{seedu/address => unicash}/logic/commands/GetTotalExpenditureCommandTest.java (85%) rename src/test/java/{seedu/address => unicash}/logic/commands/HelpCommandUniCashTest.java (62%) rename src/test/java/{seedu/address => unicash}/logic/commands/ListCommandTest.java (59%) rename src/test/java/{seedu/address => unicash}/logic/parser/AddTransactionCommandParserTest.java (63%) rename src/test/java/{seedu/address => unicash}/logic/parser/AddressBookParserTest.java (72%) rename src/test/java/{seedu/address => unicash}/logic/parser/ArgumentTokenizerTest.java (99%) rename src/test/java/{seedu/address => unicash}/logic/parser/CommandParserTestUtil.java (79%) rename src/test/java/{seedu/address => unicash}/logic/parser/DeleteTransactionCommandParserTest.java (83%) rename src/test/java/{seedu/address => unicash}/logic/parser/EditTransactionCommandParserTest.java (70%) rename src/test/java/{seedu/address => unicash}/logic/parser/FindCommandParserTest.java (53%) rename src/test/java/{seedu/address => unicash}/logic/parser/GetTotalExpenditureCommandParserTest.java (76%) rename src/test/java/{seedu/address => unicash}/logic/parser/ListCommandParserTest.java (71%) rename src/test/java/{seedu/address => unicash}/logic/parser/ParserUtilTest.java (65%) rename src/test/java/{seedu/address => unicash}/model/ModelManagerTest.java (75%) rename src/test/java/{seedu/address => unicash}/model/UniCashTest.java (87%) rename src/test/java/{seedu/address => unicash}/model/UserPrefsTest.java (76%) rename src/test/java/{seedu/address => unicash}/model/category/CategoryTest.java (93%) rename src/test/java/{seedu/address => unicash}/model/transaction/AmountTest.java (83%) rename src/test/java/{seedu/address => unicash}/model/transaction/DateTimeTest.java (88%) rename src/test/java/{seedu/address => unicash}/model/transaction/LocationTest.java (89%) rename src/test/java/{seedu/address => unicash}/model/transaction/NameTest.java (83%) rename src/test/java/{seedu/address => unicash}/model/transaction/TransactionListTest.java (93%) rename src/test/java/{seedu/address => unicash}/model/transaction/TransactionNameContainsKeywordsPredicateTest.java (97%) create mode 100644 src/test/java/unicash/model/transaction/TransactionTest.java rename src/test/java/{seedu/address => unicash}/model/transaction/TypeTest.java (87%) rename src/test/java/{seedu/address => unicash}/storage/JsonAdaptedTransactionTest.java (76%) rename src/test/java/{seedu/address => unicash}/storage/JsonSerializableUniCashTest.java (85%) rename src/test/java/{seedu/address => unicash}/storage/JsonUniCashStorageTest.java (89%) rename src/test/java/{seedu/address => unicash}/storage/JsonUserPrefsStorageTest.java (86%) rename src/test/java/{seedu/address => unicash}/storage/StorageManagerTest.java (87%) rename src/test/java/{seedu/address => unicash}/testutil/Assert.java (97%) rename src/test/java/{seedu/address => unicash}/testutil/EditTransactionDescriptorBuilder.java (87%) rename src/test/java/{seedu/address => unicash}/testutil/SerializableTestClass.java (98%) rename src/test/java/{seedu/address => unicash}/testutil/TestUtil.java (90%) rename src/test/java/{seedu/address => unicash}/testutil/TransactionBuilder.java (88%) create mode 100644 src/test/java/unicash/testutil/TransactionUtil.java rename src/test/java/{seedu/address => unicash}/testutil/TypicalIndexes.java (88%) create mode 100644 src/test/java/unicash/testutil/TypicalTransactions.java rename src/test/java/{seedu/address => unicash}/testutil/UniCashBuilder.java (85%) rename src/test/java/{seedu/address => unicash}/ui/TestFxmlObject.java (97%) rename src/test/java/{seedu/address => unicash}/ui/UiPartTest.java (68%) diff --git a/build.gradle b/build.gradle index a2951cc709e..3991cde51f8 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'jacoco' } -mainClassName = 'seedu.address.Main' +mainClassName = 'unicash.Main' sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 @@ -66,7 +66,7 @@ dependencies { } shadowJar { - archiveFileName = 'addressbook.jar' + archiveFileName = 'unicash.jar' } defaultTasks 'clean', 'test' diff --git a/docs/SettingUp.md b/docs/SettingUp.md index 275445bd551..213c6bb2e1b 100644 --- a/docs/SettingUp.md +++ b/docs/SettingUp.md @@ -23,7 +23,7 @@ If you plan to use Intellij IDEA (highly recommended): 1. **Import the project as a Gradle project**: Follow the guide [_[se-edu/guides] IDEA: Importing a Gradle project_](https://se-education.org/guides/tutorials/intellijImportGradleProject.html) to import the project into IDEA.
:exclamation: Note: Importing a Gradle project is slightly different from importing a normal Java project. 1. **Verify the setup**: - 1. Run the `seedu.address.Main` and try a few commands. + 1. Run the `seedu.address.Main` [OR] `unicash.Main` and try a few commands. 1. [Run the tests](Testing.md) to ensure they all pass. -------------------------------------------------------------------------------------------------------------------- diff --git a/docs/Testing.md b/docs/Testing.md index 8a99e82438a..18df53dcd87 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -30,7 +30,10 @@ This project has three types of tests: 1. *Unit tests* targeting the lowest level methods/classes.
e.g. `seedu.address.commons.StringUtilTest` -1. *Integration tests* that are checking the integration of multiple code units (those code units are assumed to be working).
- e.g. `seedu.address.storage.StorageManagerTest` -1. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.
+ e.g. `unicash.commons.util.StringUtilTest` +2. *Integration tests* that are checking the integration of multiple code units (those code units are assumed to be working).
+ e.g. `seedu.address.storage.StorageManagerTest` + e.g `unicash.storage.StorageManagerTest` +3. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.
e.g. `seedu.address.logic.LogicManagerTest` + e.g. `unicash.logic.LogicManagerTest` diff --git a/src/main/java/seedu/address/logic/parser/AddTransactionCommandParser.java b/src/main/java/seedu/address/logic/parser/AddTransactionCommandParser.java deleted file mode 100644 index 6e7181e36bb..00000000000 --- a/src/main/java/seedu/address/logic/parser/AddTransactionCommandParser.java +++ /dev/null @@ -1,76 +0,0 @@ -package seedu.address.logic.parser; - -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; - -import java.util.Set; -import java.util.stream.Stream; - -import seedu.address.logic.commands.AddTransactionCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; - -/** - * Parses input arguments and creates a new AddTransactionCommand object - */ -public class AddTransactionCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the AddCommand - * and returns an AddTransactionCommand object for execution. - * - * @throws ParseException if the user input does not conform the expected format - */ - public AddTransactionCommand parse(String args) throws ParseException { - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_TYPE, PREFIX_AMOUNT, PREFIX_DATETIME, - PREFIX_CATEGORY, PREFIX_LOCATION); - - // Check if mandatory fields (name, amount, type) are present - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_AMOUNT, PREFIX_TYPE) - || !argMultimap.getPreamble().isEmpty()) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, - AddTransactionCommand.MESSAGE_USAGE)); - } - - // Check for duplicates - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_TYPE, PREFIX_AMOUNT, PREFIX_DATETIME, - PREFIX_CATEGORY, PREFIX_LOCATION); - - Name name = ParserUtil.parseTransactionName(argMultimap.getValue(PREFIX_NAME).get()); - Amount amount = ParserUtil.parseAmount(argMultimap.getValue(PREFIX_AMOUNT).get()); - Type type = ParserUtil.parseType(argMultimap.getValue(PREFIX_TYPE).get()); - - String dateTimeString = argMultimap.getValue(PREFIX_DATETIME).orElse(""); - DateTime dateTime = ParserUtil.parseDateTime(dateTimeString); - - String locationString = argMultimap.getValue(PREFIX_LOCATION).orElse(""); - Location location = ParserUtil.parseLocation(locationString); - - Set categoryList = ParserUtil.parseCategories(argMultimap.getAllValues(PREFIX_CATEGORY)); - - Transaction transaction = new Transaction(name, type, amount, dateTime, location, categoryList); - - return new AddTransactionCommand(transaction); - } - - /** - * Returns true if none of the prefixes contains empty {@code Optional} values in the given - * {@code ArgumentMultimap}. - */ - private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { - return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); - } - -} diff --git a/src/main/java/seedu/address/AppParameters.java b/src/main/java/unicash/AppParameters.java similarity index 92% rename from src/main/java/seedu/address/AppParameters.java rename to src/main/java/unicash/AppParameters.java index 3d603622d4e..9b6ac588bcb 100644 --- a/src/main/java/seedu/address/AppParameters.java +++ b/src/main/java/unicash/AppParameters.java @@ -1,4 +1,4 @@ -package seedu.address; +package unicash; import java.nio.file.Path; import java.nio.file.Paths; @@ -7,9 +7,9 @@ import java.util.logging.Logger; import javafx.application.Application; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.util.FileUtil; -import seedu.address.commons.util.ToStringBuilder; +import unicash.commons.core.LogsCenter; +import unicash.commons.util.FileUtil; +import unicash.commons.util.ToStringBuilder; /** * Represents the parsed command-line parameters given to the application. diff --git a/src/main/java/seedu/address/Main.java b/src/main/java/unicash/Main.java similarity index 96% rename from src/main/java/seedu/address/Main.java rename to src/main/java/unicash/Main.java index ec1b7958746..b3eec6baeef 100644 --- a/src/main/java/seedu/address/Main.java +++ b/src/main/java/unicash/Main.java @@ -1,9 +1,9 @@ -package seedu.address; +package unicash; import java.util.logging.Logger; import javafx.application.Application; -import seedu.address.commons.core.LogsCenter; +import unicash.commons.core.LogsCenter; /** * The main entry point to the application. diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/unicash/MainApp.java similarity index 86% rename from src/main/java/seedu/address/MainApp.java rename to src/main/java/unicash/MainApp.java index 145e8faa138..cba40628994 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/unicash/MainApp.java @@ -1,4 +1,4 @@ -package seedu.address; +package unicash; import java.io.IOException; import java.nio.file.Path; @@ -7,29 +7,29 @@ import javafx.application.Application; import javafx.stage.Stage; -import seedu.address.commons.core.Config; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.core.Version; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.commons.util.ConfigUtil; -import seedu.address.commons.util.StringUtil; -import seedu.address.logic.Logic; -import seedu.address.logic.LogicManager; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; -import seedu.address.model.util.SampleDataUtil; -import seedu.address.storage.JsonUniCashStorage; -import seedu.address.storage.JsonUserPrefsStorage; -import seedu.address.storage.Storage; -import seedu.address.storage.StorageManager; -import seedu.address.storage.UniCashStorage; -import seedu.address.storage.UserPrefsStorage; -import seedu.address.ui.Ui; -import seedu.address.ui.UiManager; +import unicash.commons.core.Config; +import unicash.commons.core.LogsCenter; +import unicash.commons.core.Version; +import unicash.commons.exceptions.DataLoadingException; +import unicash.commons.util.ConfigUtil; +import unicash.commons.util.StringUtil; +import unicash.logic.Logic; +import unicash.logic.LogicManager; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.ReadOnlyUniCash; +import unicash.model.ReadOnlyUserPrefs; +import unicash.model.UniCash; +import unicash.model.UserPrefs; +import unicash.model.util.SampleDataUtil; +import unicash.storage.JsonUniCashStorage; +import unicash.storage.JsonUserPrefsStorage; +import unicash.storage.Storage; +import unicash.storage.StorageManager; +import unicash.storage.UniCashStorage; +import unicash.storage.UserPrefsStorage; +import unicash.ui.Ui; +import unicash.ui.UiManager; /** * Runs the application. diff --git a/src/main/java/seedu/address/commons/core/Config.java b/src/main/java/unicash/commons/core/Config.java similarity index 94% rename from src/main/java/seedu/address/commons/core/Config.java rename to src/main/java/unicash/commons/core/Config.java index 485f85a5e05..32ba2eafdea 100644 --- a/src/main/java/seedu/address/commons/core/Config.java +++ b/src/main/java/unicash/commons/core/Config.java @@ -1,11 +1,11 @@ -package seedu.address.commons.core; +package unicash.commons.core; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Objects; import java.util.logging.Level; -import seedu.address.commons.util.ToStringBuilder; +import unicash.commons.util.ToStringBuilder; /** * Config values used by the app diff --git a/src/main/java/seedu/address/commons/core/GuiSettings.java b/src/main/java/unicash/commons/core/GuiSettings.java similarity index 96% rename from src/main/java/seedu/address/commons/core/GuiSettings.java rename to src/main/java/unicash/commons/core/GuiSettings.java index a97a86ee8d7..7f71580a0c0 100644 --- a/src/main/java/seedu/address/commons/core/GuiSettings.java +++ b/src/main/java/unicash/commons/core/GuiSettings.java @@ -1,10 +1,10 @@ -package seedu.address.commons.core; +package unicash.commons.core; import java.awt.Point; import java.io.Serializable; import java.util.Objects; -import seedu.address.commons.util.ToStringBuilder; +import unicash.commons.util.ToStringBuilder; /** * A Serializable class that contains the GUI settings. diff --git a/src/main/java/seedu/address/commons/core/LogsCenter.java b/src/main/java/unicash/commons/core/LogsCenter.java similarity index 99% rename from src/main/java/seedu/address/commons/core/LogsCenter.java rename to src/main/java/unicash/commons/core/LogsCenter.java index 8cf8e15a0f0..998474d2531 100644 --- a/src/main/java/seedu/address/commons/core/LogsCenter.java +++ b/src/main/java/unicash/commons/core/LogsCenter.java @@ -1,4 +1,4 @@ -package seedu.address.commons.core; +package unicash.commons.core; import static java.util.Objects.requireNonNull; diff --git a/src/main/java/seedu/address/commons/core/Version.java b/src/main/java/unicash/commons/core/Version.java similarity index 98% rename from src/main/java/seedu/address/commons/core/Version.java rename to src/main/java/unicash/commons/core/Version.java index 491d24559b4..d0104fd9ce8 100644 --- a/src/main/java/seedu/address/commons/core/Version.java +++ b/src/main/java/unicash/commons/core/Version.java @@ -1,4 +1,4 @@ -package seedu.address.commons.core; +package unicash.commons.core; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/main/java/seedu/address/commons/core/index/Index.java b/src/main/java/unicash/commons/core/index/Index.java similarity index 95% rename from src/main/java/seedu/address/commons/core/index/Index.java rename to src/main/java/unicash/commons/core/index/Index.java index dd170d8b68d..efaab2d3d76 100644 --- a/src/main/java/seedu/address/commons/core/index/Index.java +++ b/src/main/java/unicash/commons/core/index/Index.java @@ -1,6 +1,6 @@ -package seedu.address.commons.core.index; +package unicash.commons.core.index; -import seedu.address.commons.util.ToStringBuilder; +import unicash.commons.util.ToStringBuilder; /** * Represents a zero-based or one-based index. diff --git a/src/main/java/seedu/address/commons/enums/TransactionType.java b/src/main/java/unicash/commons/enums/TransactionType.java similarity index 98% rename from src/main/java/seedu/address/commons/enums/TransactionType.java rename to src/main/java/unicash/commons/enums/TransactionType.java index 92a01a462e9..af0215092b6 100644 --- a/src/main/java/seedu/address/commons/enums/TransactionType.java +++ b/src/main/java/unicash/commons/enums/TransactionType.java @@ -1,4 +1,4 @@ -package seedu.address.commons.enums; +package unicash.commons.enums; import java.util.Arrays; import java.util.StringJoiner; diff --git a/src/main/java/seedu/address/commons/exceptions/DataLoadingException.java b/src/main/java/unicash/commons/exceptions/DataLoadingException.java similarity index 82% rename from src/main/java/seedu/address/commons/exceptions/DataLoadingException.java rename to src/main/java/unicash/commons/exceptions/DataLoadingException.java index 9904ba47afe..19652d8b466 100644 --- a/src/main/java/seedu/address/commons/exceptions/DataLoadingException.java +++ b/src/main/java/unicash/commons/exceptions/DataLoadingException.java @@ -1,4 +1,4 @@ -package seedu.address.commons.exceptions; +package unicash.commons.exceptions; /** * Represents an error during loading of data from a file. diff --git a/src/main/java/seedu/address/commons/exceptions/IllegalValueException.java b/src/main/java/unicash/commons/exceptions/IllegalValueException.java similarity index 93% rename from src/main/java/seedu/address/commons/exceptions/IllegalValueException.java rename to src/main/java/unicash/commons/exceptions/IllegalValueException.java index 19124db485c..40bcf3268ed 100644 --- a/src/main/java/seedu/address/commons/exceptions/IllegalValueException.java +++ b/src/main/java/unicash/commons/exceptions/IllegalValueException.java @@ -1,4 +1,4 @@ -package seedu.address.commons.exceptions; +package unicash.commons.exceptions; /** * Signals that some given data does not fulfill some constraints. diff --git a/src/main/java/seedu/address/commons/util/AppUtil.java b/src/main/java/unicash/commons/util/AppUtil.java similarity index 94% rename from src/main/java/seedu/address/commons/util/AppUtil.java rename to src/main/java/unicash/commons/util/AppUtil.java index 49a72b70669..9cc5ceea8dc 100644 --- a/src/main/java/seedu/address/commons/util/AppUtil.java +++ b/src/main/java/unicash/commons/util/AppUtil.java @@ -1,9 +1,9 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static java.util.Objects.requireNonNull; import javafx.scene.image.Image; -import seedu.address.MainApp; +import unicash.MainApp; /** * A container for App specific utility functions diff --git a/src/main/java/seedu/address/commons/util/CollectionUtil.java b/src/main/java/unicash/commons/util/CollectionUtil.java similarity index 96% rename from src/main/java/seedu/address/commons/util/CollectionUtil.java rename to src/main/java/unicash/commons/util/CollectionUtil.java index df606afbe2b..a2f283775dd 100644 --- a/src/main/java/seedu/address/commons/util/CollectionUtil.java +++ b/src/main/java/unicash/commons/util/CollectionUtil.java @@ -1,4 +1,4 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static java.util.Objects.requireNonNull; diff --git a/src/main/java/seedu/address/commons/util/ConfigUtil.java b/src/main/java/unicash/commons/util/ConfigUtil.java similarity index 78% rename from src/main/java/seedu/address/commons/util/ConfigUtil.java rename to src/main/java/unicash/commons/util/ConfigUtil.java index 9d34466ff38..52e706613de 100644 --- a/src/main/java/seedu/address/commons/util/ConfigUtil.java +++ b/src/main/java/unicash/commons/util/ConfigUtil.java @@ -1,11 +1,11 @@ -package seedu.address.commons.util; +package unicash.commons.util; import java.io.IOException; import java.nio.file.Path; import java.util.Optional; -import seedu.address.commons.core.Config; -import seedu.address.commons.exceptions.DataLoadingException; +import unicash.commons.core.Config; +import unicash.commons.exceptions.DataLoadingException; /** * A class for accessing the Config File. diff --git a/src/main/java/seedu/address/commons/util/FileUtil.java b/src/main/java/unicash/commons/util/FileUtil.java similarity index 98% rename from src/main/java/seedu/address/commons/util/FileUtil.java rename to src/main/java/unicash/commons/util/FileUtil.java index d449be186c1..3aebb36d614 100644 --- a/src/main/java/seedu/address/commons/util/FileUtil.java +++ b/src/main/java/unicash/commons/util/FileUtil.java @@ -1,4 +1,4 @@ -package seedu.address.commons.util; +package unicash.commons.util; import java.io.IOException; import java.nio.file.Files; diff --git a/src/main/java/seedu/address/commons/util/JsonUtil.java b/src/main/java/unicash/commons/util/JsonUtil.java similarity index 97% rename from src/main/java/seedu/address/commons/util/JsonUtil.java rename to src/main/java/unicash/commons/util/JsonUtil.java index c9b067520a4..319dad220cf 100644 --- a/src/main/java/seedu/address/commons/util/JsonUtil.java +++ b/src/main/java/unicash/commons/util/JsonUtil.java @@ -1,4 +1,4 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static java.util.Objects.requireNonNull; @@ -20,8 +20,8 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.exceptions.DataLoadingException; +import unicash.commons.core.LogsCenter; +import unicash.commons.exceptions.DataLoadingException; /** * Converts a Java object instance to JSON and vice versa diff --git a/src/main/java/seedu/address/commons/util/StringUtil.java b/src/main/java/unicash/commons/util/StringUtil.java similarity index 96% rename from src/main/java/seedu/address/commons/util/StringUtil.java rename to src/main/java/unicash/commons/util/StringUtil.java index 1d735b3f147..1b20ce8694f 100644 --- a/src/main/java/seedu/address/commons/util/StringUtil.java +++ b/src/main/java/unicash/commons/util/StringUtil.java @@ -1,7 +1,7 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; +import static unicash.commons.util.AppUtil.checkArgument; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/src/main/java/seedu/address/commons/util/ToStringBuilder.java b/src/main/java/unicash/commons/util/ToStringBuilder.java similarity index 97% rename from src/main/java/seedu/address/commons/util/ToStringBuilder.java rename to src/main/java/unicash/commons/util/ToStringBuilder.java index d979b926734..72a944d0cb1 100644 --- a/src/main/java/seedu/address/commons/util/ToStringBuilder.java +++ b/src/main/java/unicash/commons/util/ToStringBuilder.java @@ -1,4 +1,4 @@ -package seedu.address.commons.util; +package unicash.commons.util; /** * Builds a string representation of an object that is suitable as the return value of {@link Object#toString()}. diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/unicash/logic/Logic.java similarity index 76% rename from src/main/java/seedu/address/logic/Logic.java rename to src/main/java/unicash/logic/Logic.java index e65eeb0f3d0..e5f8ec339f0 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/unicash/logic/Logic.java @@ -1,13 +1,13 @@ -package seedu.address.logic; +package unicash.logic; import java.nio.file.Path; import javafx.collections.ObservableList; -import seedu.address.commons.core.GuiSettings; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.transaction.Transaction; +import unicash.commons.core.GuiSettings; +import unicash.logic.commands.CommandResult; +import unicash.logic.commands.exceptions.CommandException; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.transaction.Transaction; /** * API of the Logic component diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/unicash/logic/LogicManager.java similarity index 81% rename from src/main/java/seedu/address/logic/LogicManager.java rename to src/main/java/unicash/logic/LogicManager.java index 05bf30eb483..85f2877db2b 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/unicash/logic/LogicManager.java @@ -1,4 +1,4 @@ -package seedu.address.logic; +package unicash.logic; import java.io.IOException; import java.nio.file.AccessDeniedException; @@ -6,16 +6,16 @@ import java.util.logging.Logger; import javafx.collections.ObservableList; -import seedu.address.commons.core.GuiSettings; -import seedu.address.commons.core.LogsCenter; -import seedu.address.logic.commands.Command; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.AddressBookParser; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.Model; -import seedu.address.model.transaction.Transaction; -import seedu.address.storage.Storage; +import unicash.commons.core.GuiSettings; +import unicash.commons.core.LogsCenter; +import unicash.logic.commands.Command; +import unicash.logic.commands.CommandResult; +import unicash.logic.commands.exceptions.CommandException; +import unicash.logic.parser.AddressBookParser; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.Model; +import unicash.model.transaction.Transaction; +import unicash.storage.Storage; /** * The main LogicManager of the app. diff --git a/src/main/java/seedu/address/logic/UniCashMessages.java b/src/main/java/unicash/logic/UniCashMessages.java similarity index 94% rename from src/main/java/seedu/address/logic/UniCashMessages.java rename to src/main/java/unicash/logic/UniCashMessages.java index 391c87d5cb8..550bab91f5d 100644 --- a/src/main/java/seedu/address/logic/UniCashMessages.java +++ b/src/main/java/unicash/logic/UniCashMessages.java @@ -1,11 +1,11 @@ -package seedu.address.logic; +package unicash.logic; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import seedu.address.logic.parser.Prefix; -import seedu.address.model.transaction.Transaction; +import unicash.logic.parser.Prefix; +import unicash.model.transaction.Transaction; /** * Container for user visible messages. diff --git a/src/main/java/seedu/address/logic/commands/AddTransactionCommand.java b/src/main/java/unicash/logic/commands/AddTransactionCommand.java similarity index 56% rename from src/main/java/seedu/address/logic/commands/AddTransactionCommand.java rename to src/main/java/unicash/logic/commands/AddTransactionCommand.java index 3e600f79ded..f123860fe8a 100644 --- a/src/main/java/seedu/address/logic/commands/AddTransactionCommand.java +++ b/src/main/java/unicash/logic/commands/AddTransactionCommand.java @@ -1,18 +1,13 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.transaction.Transaction; +import unicash.commons.util.ToStringBuilder; +import unicash.logic.UniCashMessages; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; +import unicash.model.transaction.Transaction; +import unicash.logic.parser.CliSyntax; /** * Adds a transaction to UniCash. @@ -22,19 +17,19 @@ public class AddTransactionCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a transaction to UniCash. " + "Parameters: " - + PREFIX_NAME + "NAME " - + PREFIX_TYPE + "TYPE " - + PREFIX_AMOUNT + "AMOUNT " - + PREFIX_DATETIME + "DATETIME " - + PREFIX_LOCATION + "LOCATION " - + "[" + PREFIX_CATEGORY + "CATEGORY]...\n" + + CliSyntax.PREFIX_NAME + "NAME " + + CliSyntax.PREFIX_TYPE + "TYPE " + + CliSyntax.PREFIX_AMOUNT + "AMOUNT " + + CliSyntax.PREFIX_DATETIME + "DATETIME " + + CliSyntax.PREFIX_LOCATION + "LOCATION " + + "[" + CliSyntax.PREFIX_CATEGORY + "CATEGORY]...\n" + "Example: " + COMMAND_WORD + " " - + PREFIX_NAME + "Buying groceries " - + PREFIX_TYPE + "expense " - + PREFIX_AMOUNT + "300 " - + PREFIX_DATETIME + "18-08-2001 19:30 " - + PREFIX_LOCATION + "ntuc" - + PREFIX_CATEGORY + "household expenses"; + + CliSyntax.PREFIX_NAME + "Buying groceries " + + CliSyntax.PREFIX_TYPE + "expense " + + CliSyntax.PREFIX_AMOUNT + "300 " + + CliSyntax.PREFIX_DATETIME + "18-08-2001 19:30 " + + CliSyntax.PREFIX_LOCATION + "ntuc" + + CliSyntax.PREFIX_CATEGORY + "household expenses"; public static final String MESSAGE_SUCCESS = "New transaction added: %1$s"; diff --git a/src/main/java/seedu/address/logic/commands/ClearTransactionsCommand.java b/src/main/java/unicash/logic/commands/ClearTransactionsCommand.java similarity index 82% rename from src/main/java/seedu/address/logic/commands/ClearTransactionsCommand.java rename to src/main/java/unicash/logic/commands/ClearTransactionsCommand.java index ada95e1d5b7..2f10a4ae192 100644 --- a/src/main/java/seedu/address/logic/commands/ClearTransactionsCommand.java +++ b/src/main/java/unicash/logic/commands/ClearTransactionsCommand.java @@ -1,9 +1,9 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; -import seedu.address.model.Model; -import seedu.address.model.UniCash; +import unicash.model.Model; +import unicash.model.UniCash; /** * Clears all transactions in UniCash. diff --git a/src/main/java/seedu/address/logic/commands/Command.java b/src/main/java/unicash/logic/commands/Command.java similarity index 78% rename from src/main/java/seedu/address/logic/commands/Command.java rename to src/main/java/unicash/logic/commands/Command.java index 64f18992160..72e76aff19a 100644 --- a/src/main/java/seedu/address/logic/commands/Command.java +++ b/src/main/java/unicash/logic/commands/Command.java @@ -1,7 +1,7 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; /** * Represents a command with hidden internal logic and the ability to be executed. diff --git a/src/main/java/seedu/address/logic/commands/CommandResult.java b/src/main/java/unicash/logic/commands/CommandResult.java similarity index 95% rename from src/main/java/seedu/address/logic/commands/CommandResult.java rename to src/main/java/unicash/logic/commands/CommandResult.java index 249b6072d0d..c585e68118d 100644 --- a/src/main/java/seedu/address/logic/commands/CommandResult.java +++ b/src/main/java/unicash/logic/commands/CommandResult.java @@ -1,10 +1,10 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; import java.util.Objects; -import seedu.address.commons.util.ToStringBuilder; +import unicash.commons.util.ToStringBuilder; /** * Represents the result of a command execution. diff --git a/src/main/java/seedu/address/logic/commands/DeleteTransactionCommand.java b/src/main/java/unicash/logic/commands/DeleteTransactionCommand.java similarity index 86% rename from src/main/java/seedu/address/logic/commands/DeleteTransactionCommand.java rename to src/main/java/unicash/logic/commands/DeleteTransactionCommand.java index 117bec6e2e7..a896563dd20 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteTransactionCommand.java +++ b/src/main/java/unicash/logic/commands/DeleteTransactionCommand.java @@ -1,15 +1,15 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; import java.util.List; -import seedu.address.commons.core.index.Index; -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.transaction.Transaction; +import unicash.commons.core.index.Index; +import unicash.commons.util.ToStringBuilder; +import unicash.logic.UniCashMessages; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; +import unicash.model.transaction.Transaction; /** * This class handles the deletion of a Transaction from the UniCa$h database. diff --git a/src/main/java/seedu/address/logic/commands/EditTransactionCommand.java b/src/main/java/unicash/logic/commands/EditTransactionCommand.java similarity index 89% rename from src/main/java/seedu/address/logic/commands/EditTransactionCommand.java rename to src/main/java/unicash/logic/commands/EditTransactionCommand.java index bda0ecf66e9..655c0ca674f 100644 --- a/src/main/java/seedu/address/logic/commands/EditTransactionCommand.java +++ b/src/main/java/unicash/logic/commands/EditTransactionCommand.java @@ -1,13 +1,13 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TRANSACTIONS; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_NAME; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; +import static unicash.model.Model.PREDICATE_SHOW_ALL_TRANSACTIONS; import java.util.Collections; import java.util.HashSet; @@ -16,19 +16,19 @@ import java.util.Optional; import java.util.Set; -import seedu.address.commons.core.index.Index; -import seedu.address.commons.util.CollectionUtil; -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; +import unicash.commons.core.index.Index; +import unicash.commons.util.CollectionUtil; +import unicash.commons.util.ToStringBuilder; +import unicash.logic.UniCashMessages; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; /** * Edits the details of an existing transaction in the transactions list. diff --git a/src/main/java/seedu/address/logic/commands/ExitCommandUniCash.java b/src/main/java/unicash/logic/commands/ExitCommandUniCash.java similarity index 84% rename from src/main/java/seedu/address/logic/commands/ExitCommandUniCash.java rename to src/main/java/unicash/logic/commands/ExitCommandUniCash.java index d43879a02c3..012c6b6696d 100644 --- a/src/main/java/seedu/address/logic/commands/ExitCommandUniCash.java +++ b/src/main/java/unicash/logic/commands/ExitCommandUniCash.java @@ -1,6 +1,6 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; -import seedu.address.model.Model; +import unicash.model.Model; /** * Terminates UniCa$h. diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/unicash/logic/commands/FindCommand.java similarity index 87% rename from src/main/java/seedu/address/logic/commands/FindCommand.java rename to src/main/java/unicash/logic/commands/FindCommand.java index cc750e1ac22..06c065a6a85 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/unicash/logic/commands/FindCommand.java @@ -1,11 +1,11 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.logic.UniCashMessages; -import seedu.address.model.Model; -import seedu.address.model.transaction.TransactionNameContainsKeywordsPredicate; +import unicash.commons.util.ToStringBuilder; +import unicash.logic.UniCashMessages; +import unicash.model.Model; +import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; /** * Finds and lists all transactions in UniCa$h whose name contains any of the argument keywords. diff --git a/src/main/java/seedu/address/logic/commands/GetTotalExpenditureCommand.java b/src/main/java/unicash/logic/commands/GetTotalExpenditureCommand.java similarity index 88% rename from src/main/java/seedu/address/logic/commands/GetTotalExpenditureCommand.java rename to src/main/java/unicash/logic/commands/GetTotalExpenditureCommand.java index 1068d921da2..3ea7525144d 100644 --- a/src/main/java/seedu/address/logic/commands/GetTotalExpenditureCommand.java +++ b/src/main/java/unicash/logic/commands/GetTotalExpenditureCommand.java @@ -1,16 +1,16 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; import java.time.Month; -import seedu.address.commons.enums.TransactionType; -import seedu.address.commons.util.ToStringBuilder; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.category.Category; +import unicash.commons.enums.TransactionType; +import unicash.commons.util.ToStringBuilder; +import unicash.logic.UniCashMessages; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; +import unicash.model.category.Category; /** * Calculates and returns the total expenditure of a user in a given month and (optionally) category. diff --git a/src/main/java/seedu/address/logic/commands/HelpCommandUniCash.java b/src/main/java/unicash/logic/commands/HelpCommandUniCash.java similarity index 88% rename from src/main/java/seedu/address/logic/commands/HelpCommandUniCash.java rename to src/main/java/unicash/logic/commands/HelpCommandUniCash.java index 7105bfc923d..5907c86a78c 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommandUniCash.java +++ b/src/main/java/unicash/logic/commands/HelpCommandUniCash.java @@ -1,6 +1,6 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; -import seedu.address.model.Model; +import unicash.model.Model; /** * Format full help instructions for every command for display. diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/unicash/logic/commands/ListCommand.java similarity index 82% rename from src/main/java/seedu/address/logic/commands/ListCommand.java rename to src/main/java/unicash/logic/commands/ListCommand.java index d323c991b0f..c61e5d1dc97 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/unicash/logic/commands/ListCommand.java @@ -1,12 +1,11 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TRANSACTIONS; import java.util.logging.Level; import java.util.logging.Logger; -import seedu.address.model.Model; +import unicash.model.Model; /** * Lists all persons in the address book to the user. @@ -29,7 +28,7 @@ public class ListCommand extends Command { public CommandResult execute(Model model) { requireNonNull(model); logger.log(Level.INFO, "Executing list command"); - model.updateFilteredTransactionList(PREDICATE_SHOW_ALL_TRANSACTIONS); + model.updateFilteredTransactionList(Model.PREDICATE_SHOW_ALL_TRANSACTIONS); logger.log(Level.INFO, "List command executed successfully"); return new CommandResult(MESSAGE_SUCCESS); } diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/unicash/logic/commands/exceptions/CommandException.java similarity index 89% rename from src/main/java/seedu/address/logic/commands/exceptions/CommandException.java rename to src/main/java/unicash/logic/commands/exceptions/CommandException.java index a16bd14f2cd..5ba6f1c5d89 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/unicash/logic/commands/exceptions/CommandException.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands.exceptions; +package unicash.logic.commands.exceptions; /** * Represents an error which occurs during execution of a {@link Command}. diff --git a/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java b/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java new file mode 100644 index 00000000000..fa4f1307ece --- /dev/null +++ b/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java @@ -0,0 +1,69 @@ +package unicash.logic.parser; + +import java.util.Set; +import java.util.stream.Stream; + +import unicash.logic.commands.AddTransactionCommand; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; +import unicash.logic.UniCashMessages; + +/** + * Parses input arguments and creates a new AddTransactionCommand object + */ +public class AddTransactionCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the AddCommand + * and returns an AddTransactionCommand object for execution. + * + * @throws ParseException if the user input does not conform the expected format + */ + public AddTransactionCommand parse(String args) throws ParseException { + ArgumentMultimap argMultimap = + ArgumentTokenizer.tokenize(args, CliSyntax.PREFIX_NAME, CliSyntax.PREFIX_TYPE, CliSyntax.PREFIX_AMOUNT, CliSyntax.PREFIX_DATETIME, + CliSyntax.PREFIX_CATEGORY, CliSyntax.PREFIX_LOCATION); + + // Check if mandatory fields (name, amount, type) are present + if (!arePrefixesPresent(argMultimap, CliSyntax.PREFIX_NAME, CliSyntax.PREFIX_AMOUNT, CliSyntax.PREFIX_TYPE) + || !argMultimap.getPreamble().isEmpty()) { + throw new ParseException(String.format(UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT, + AddTransactionCommand.MESSAGE_USAGE)); + } + + // Check for duplicates + argMultimap.verifyNoDuplicatePrefixesFor(CliSyntax.PREFIX_NAME, CliSyntax.PREFIX_TYPE, CliSyntax.PREFIX_AMOUNT, CliSyntax.PREFIX_DATETIME, + CliSyntax.PREFIX_CATEGORY, CliSyntax.PREFIX_LOCATION); + + Name name = ParserUtil.parseTransactionName(argMultimap.getValue(CliSyntax.PREFIX_NAME).get()); + Amount amount = ParserUtil.parseAmount(argMultimap.getValue(CliSyntax.PREFIX_AMOUNT).get()); + Type type = ParserUtil.parseType(argMultimap.getValue(CliSyntax.PREFIX_TYPE).get()); + + String dateTimeString = argMultimap.getValue(CliSyntax.PREFIX_DATETIME).orElse(""); + DateTime dateTime = ParserUtil.parseDateTime(dateTimeString); + + String locationString = argMultimap.getValue(CliSyntax.PREFIX_LOCATION).orElse(""); + Location location = ParserUtil.parseLocation(locationString); + + Set categoryList = ParserUtil.parseCategories(argMultimap.getAllValues(CliSyntax.PREFIX_CATEGORY)); + + Transaction transaction = new Transaction(name, type, amount, dateTime, location, categoryList); + + return new AddTransactionCommand(transaction); + } + + /** + * Returns true if none of the prefixes contains empty {@code Optional} values in the given + * {@code ArgumentMultimap}. + */ + private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { + return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); + } + +} diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/unicash/logic/parser/AddressBookParser.java similarity index 75% rename from src/main/java/seedu/address/logic/parser/AddressBookParser.java rename to src/main/java/unicash/logic/parser/AddressBookParser.java index 32488052a3a..c343f93bcad 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/unicash/logic/parser/AddressBookParser.java @@ -1,24 +1,24 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import seedu.address.commons.core.LogsCenter; -import seedu.address.logic.commands.AddTransactionCommand; -import seedu.address.logic.commands.ClearTransactionsCommand; -import seedu.address.logic.commands.Command; -import seedu.address.logic.commands.DeleteTransactionCommand; -import seedu.address.logic.commands.EditTransactionCommand; -import seedu.address.logic.commands.ExitCommandUniCash; -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.commands.GetTotalExpenditureCommand; -import seedu.address.logic.commands.HelpCommandUniCash; -import seedu.address.logic.commands.ListCommand; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.commons.core.LogsCenter; +import unicash.logic.commands.AddTransactionCommand; +import unicash.logic.commands.ClearTransactionsCommand; +import unicash.logic.commands.Command; +import unicash.logic.commands.DeleteTransactionCommand; +import unicash.logic.commands.EditTransactionCommand; +import unicash.logic.commands.ExitCommandUniCash; +import unicash.logic.commands.FindCommand; +import unicash.logic.commands.GetTotalExpenditureCommand; +import unicash.logic.commands.HelpCommandUniCash; +import unicash.logic.commands.ListCommand; +import unicash.logic.parser.exceptions.ParseException; /** diff --git a/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java b/src/main/java/unicash/logic/parser/ArgumentMultimap.java similarity index 95% rename from src/main/java/seedu/address/logic/parser/ArgumentMultimap.java rename to src/main/java/unicash/logic/parser/ArgumentMultimap.java index 4ac204a77c8..ee39db61aac 100644 --- a/src/main/java/seedu/address/logic/parser/ArgumentMultimap.java +++ b/src/main/java/unicash/logic/parser/ArgumentMultimap.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import java.util.ArrayList; import java.util.HashMap; @@ -7,8 +7,8 @@ import java.util.Optional; import java.util.stream.Stream; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.logic.UniCashMessages; +import unicash.logic.parser.exceptions.ParseException; /** * Stores mapping of prefixes to their respective arguments. diff --git a/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java b/src/main/java/unicash/logic/parser/ArgumentTokenizer.java similarity index 99% rename from src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java rename to src/main/java/unicash/logic/parser/ArgumentTokenizer.java index 5c9aebfa488..c30f217c126 100644 --- a/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java +++ b/src/main/java/unicash/logic/parser/ArgumentTokenizer.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/unicash/logic/parser/CliSyntax.java similarity index 95% rename from src/main/java/seedu/address/logic/parser/CliSyntax.java rename to src/main/java/unicash/logic/parser/CliSyntax.java index e0de6d88110..c6c92e1ecb7 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/unicash/logic/parser/CliSyntax.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; /** * Contains Command Line Interface (CLI) syntax definitions common to multiple commands diff --git a/src/main/java/seedu/address/logic/parser/DeleteTransactionCommandParser.java b/src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java similarity index 65% rename from src/main/java/seedu/address/logic/parser/DeleteTransactionCommandParser.java rename to src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java index f1c646faaba..bec045a81f6 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteTransactionCommandParser.java +++ b/src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java @@ -1,10 +1,9 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; - -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.DeleteTransactionCommand; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.commons.core.index.Index; +import unicash.logic.commands.DeleteTransactionCommand; +import unicash.logic.parser.exceptions.ParseException; +import unicash.logic.UniCashMessages; /** * Parses input arguments and creates a new DeleteTransactionCommand object @@ -23,7 +22,7 @@ public DeleteTransactionCommand parse(String args) throws ParseException { return new DeleteTransactionCommand(index); } catch (ParseException pe) { throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteTransactionCommand.MESSAGE_USAGE), pe); + String.format(UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT, DeleteTransactionCommand.MESSAGE_USAGE), pe); } } diff --git a/src/main/java/seedu/address/logic/parser/EditTransactionCommandParser.java b/src/main/java/unicash/logic/parser/EditTransactionCommandParser.java similarity index 62% rename from src/main/java/seedu/address/logic/parser/EditTransactionCommandParser.java rename to src/main/java/unicash/logic/parser/EditTransactionCommandParser.java index ea06923ed34..843671c7187 100644 --- a/src/main/java/seedu/address/logic/parser/EditTransactionCommandParser.java +++ b/src/main/java/unicash/logic/parser/EditTransactionCommandParser.java @@ -1,23 +1,17 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; import java.util.Collection; import java.util.Collections; import java.util.Optional; import java.util.Set; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.EditTransactionCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.category.Category; +import unicash.commons.core.index.Index; +import unicash.logic.commands.EditTransactionCommand; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.category.Category; +import unicash.logic.UniCashMessages; /** * Parses input arguments and creates a new EditTransactionCommand object @@ -33,51 +27,51 @@ public class EditTransactionCommandParser implements Parser categories ) { - requireAllNonNull(name, type, amount, categories, dateTime, location); + CollectionUtil.requireAllNonNull(name, type, amount, categories, dateTime, location); this.name = name; this.type = type; this.amount = amount; diff --git a/src/main/java/seedu/address/model/transaction/TransactionList.java b/src/main/java/unicash/model/transaction/TransactionList.java similarity index 90% rename from src/main/java/seedu/address/model/transaction/TransactionList.java rename to src/main/java/unicash/model/transaction/TransactionList.java index a0a1ffa0590..ab443794053 100644 --- a/src/main/java/seedu/address/model/transaction/TransactionList.java +++ b/src/main/java/unicash/model/transaction/TransactionList.java @@ -1,14 +1,15 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; +import static unicash.commons.util.CollectionUtil.requireAllNonNull; import java.util.Iterator; import java.util.List; import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import seedu.address.model.transaction.exceptions.TransactionNotFoundException; +import unicash.model.transaction.exceptions.TransactionNotFoundException; +import unicash.commons.util.CollectionUtil; /** * A list of Transactions that does not allow nulls. @@ -41,7 +42,7 @@ public void add(Transaction toAdd) { * {@code target} must exist in the list. */ public void setTransaction(Transaction target, Transaction editedTransaction) { - requireAllNonNull(target, editedTransaction); + CollectionUtil.requireAllNonNull(target, editedTransaction); int index = internalList.indexOf(target); if (index == -1) { @@ -76,7 +77,7 @@ public void setTransactions(TransactionList replacement) { * {@code transactions} must not contain null. */ public void setTransactions(List transactions) { - requireAllNonNull(transactions); + CollectionUtil.requireAllNonNull(transactions); internalList.setAll(transactions); } diff --git a/src/main/java/seedu/address/model/transaction/TransactionNameContainsKeywordsPredicate.java b/src/main/java/unicash/model/transaction/TransactionNameContainsKeywordsPredicate.java similarity index 90% rename from src/main/java/seedu/address/model/transaction/TransactionNameContainsKeywordsPredicate.java rename to src/main/java/unicash/model/transaction/TransactionNameContainsKeywordsPredicate.java index 0e1b387dedf..61b0b010e20 100644 --- a/src/main/java/seedu/address/model/transaction/TransactionNameContainsKeywordsPredicate.java +++ b/src/main/java/unicash/model/transaction/TransactionNameContainsKeywordsPredicate.java @@ -1,10 +1,10 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import java.util.List; import java.util.function.Predicate; -import seedu.address.commons.util.StringUtil; -import seedu.address.commons.util.ToStringBuilder; +import unicash.commons.util.StringUtil; +import unicash.commons.util.ToStringBuilder; /** * Tests that a {@code Transactions}'s {@code Name} matches any of the keywords given. diff --git a/src/main/java/seedu/address/model/transaction/Type.java b/src/main/java/unicash/model/transaction/Type.java similarity index 82% rename from src/main/java/seedu/address/model/transaction/Type.java rename to src/main/java/unicash/model/transaction/Type.java index ea0b2101d67..547a1fa7d5e 100644 --- a/src/main/java/seedu/address/model/transaction/Type.java +++ b/src/main/java/unicash/model/transaction/Type.java @@ -1,9 +1,10 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; +import static unicash.commons.util.AppUtil.checkArgument; -import seedu.address.commons.enums.TransactionType; +import unicash.commons.enums.TransactionType; +import unicash.commons.util.AppUtil; /** * Represents a Transaction's type. @@ -22,7 +23,7 @@ public class Type { */ public Type(String type) { requireNonNull(type); - checkArgument(isValidType(type), MESSAGE_CONSTRAINTS); + AppUtil.checkArgument(isValidType(type), MESSAGE_CONSTRAINTS); this.type = TransactionType.parseType(type); } diff --git a/src/main/java/seedu/address/model/transaction/exceptions/TransactionNotFoundException.java b/src/main/java/unicash/model/transaction/exceptions/TransactionNotFoundException.java similarity index 75% rename from src/main/java/seedu/address/model/transaction/exceptions/TransactionNotFoundException.java rename to src/main/java/unicash/model/transaction/exceptions/TransactionNotFoundException.java index 37d7e6f7569..3e1f87d4778 100644 --- a/src/main/java/seedu/address/model/transaction/exceptions/TransactionNotFoundException.java +++ b/src/main/java/unicash/model/transaction/exceptions/TransactionNotFoundException.java @@ -1,4 +1,4 @@ -package seedu.address.model.transaction.exceptions; +package unicash.model.transaction.exceptions; /** * Signals that the operation is unable to find the specified transaction. diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/unicash/model/util/SampleDataUtil.java similarity index 77% rename from src/main/java/seedu/address/model/util/SampleDataUtil.java rename to src/main/java/unicash/model/util/SampleDataUtil.java index c6ac2ced107..b3f05a47164 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/unicash/model/util/SampleDataUtil.java @@ -1,18 +1,18 @@ -package seedu.address.model.util; +package unicash.model.util; import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.UniCash; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; +import unicash.model.ReadOnlyUniCash; +import unicash.model.UniCash; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; /** * Contains utility methods for populating {@code UniCash} with sample data. diff --git a/src/main/java/seedu/address/storage/JsonAdaptedCategory.java b/src/main/java/unicash/storage/JsonAdaptedCategory.java similarity index 89% rename from src/main/java/seedu/address/storage/JsonAdaptedCategory.java rename to src/main/java/unicash/storage/JsonAdaptedCategory.java index 48221c0ff8c..c0b0499388e 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedCategory.java +++ b/src/main/java/unicash/storage/JsonAdaptedCategory.java @@ -1,10 +1,10 @@ -package seedu.address.storage; +package unicash.storage; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.category.Category; +import unicash.commons.exceptions.IllegalValueException; +import unicash.model.category.Category; /** * Jackson-friendly version of {@link Category}. diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTransaction.java b/src/main/java/unicash/storage/JsonAdaptedTransaction.java similarity index 90% rename from src/main/java/seedu/address/storage/JsonAdaptedTransaction.java rename to src/main/java/unicash/storage/JsonAdaptedTransaction.java index 3b2ba9102bd..d1afbcdb2b8 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedTransaction.java +++ b/src/main/java/unicash/storage/JsonAdaptedTransaction.java @@ -1,4 +1,4 @@ -package seedu.address.storage; +package unicash.storage; import java.util.ArrayList; import java.util.HashSet; @@ -9,14 +9,14 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; +import unicash.commons.exceptions.IllegalValueException; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; /** * Jackson-friendly version of {@link Transaction}. diff --git a/src/main/java/seedu/address/storage/JsonSerializableUniCash.java b/src/main/java/unicash/storage/JsonSerializableUniCash.java similarity index 90% rename from src/main/java/seedu/address/storage/JsonSerializableUniCash.java rename to src/main/java/unicash/storage/JsonSerializableUniCash.java index 3438b3f0b97..a947d28d8cd 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableUniCash.java +++ b/src/main/java/unicash/storage/JsonSerializableUniCash.java @@ -1,4 +1,4 @@ -package seedu.address.storage; +package unicash.storage; import java.util.ArrayList; import java.util.List; @@ -8,10 +8,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.UniCash; -import seedu.address.model.transaction.Transaction; +import unicash.commons.exceptions.IllegalValueException; +import unicash.model.ReadOnlyUniCash; +import unicash.model.UniCash; +import unicash.model.transaction.Transaction; /** * An Immutable UniCash that is serializable to JSON format. diff --git a/src/main/java/seedu/address/storage/JsonUniCashStorage.java b/src/main/java/unicash/storage/JsonUniCashStorage.java similarity index 86% rename from src/main/java/seedu/address/storage/JsonUniCashStorage.java rename to src/main/java/unicash/storage/JsonUniCashStorage.java index d0a6b255801..85b82789fcf 100644 --- a/src/main/java/seedu/address/storage/JsonUniCashStorage.java +++ b/src/main/java/unicash/storage/JsonUniCashStorage.java @@ -1,4 +1,4 @@ -package seedu.address.storage; +package unicash.storage; import static java.util.Objects.requireNonNull; @@ -7,12 +7,12 @@ import java.util.Optional; import java.util.logging.Logger; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.commons.util.FileUtil; -import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyUniCash; +import unicash.commons.core.LogsCenter; +import unicash.commons.exceptions.DataLoadingException; +import unicash.commons.exceptions.IllegalValueException; +import unicash.commons.util.FileUtil; +import unicash.commons.util.JsonUtil; +import unicash.model.ReadOnlyUniCash; /** * A class to access UniCash data stored as a json file on the hard disk. diff --git a/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java b/src/main/java/unicash/storage/JsonUserPrefsStorage.java similarity index 83% rename from src/main/java/seedu/address/storage/JsonUserPrefsStorage.java rename to src/main/java/unicash/storage/JsonUserPrefsStorage.java index 48a9754807d..aab96a6286e 100644 --- a/src/main/java/seedu/address/storage/JsonUserPrefsStorage.java +++ b/src/main/java/unicash/storage/JsonUserPrefsStorage.java @@ -1,13 +1,13 @@ -package seedu.address.storage; +package unicash.storage; import java.io.IOException; import java.nio.file.Path; import java.util.Optional; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; +import unicash.commons.exceptions.DataLoadingException; +import unicash.commons.util.JsonUtil; +import unicash.model.ReadOnlyUserPrefs; +import unicash.model.UserPrefs; /** * A class to access UserPrefs stored in the hard disk as a json file diff --git a/src/main/java/seedu/address/storage/Storage.java b/src/main/java/unicash/storage/Storage.java similarity index 72% rename from src/main/java/seedu/address/storage/Storage.java rename to src/main/java/unicash/storage/Storage.java index a9f5b8fdef1..ceb4cec3e03 100644 --- a/src/main/java/seedu/address/storage/Storage.java +++ b/src/main/java/unicash/storage/Storage.java @@ -1,13 +1,13 @@ -package seedu.address.storage; +package unicash.storage; import java.io.IOException; import java.nio.file.Path; import java.util.Optional; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; +import unicash.commons.exceptions.DataLoadingException; +import unicash.model.ReadOnlyUniCash; +import unicash.model.ReadOnlyUserPrefs; +import unicash.model.UserPrefs; /** * API of the Storage component diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/unicash/storage/StorageManager.java similarity index 89% rename from src/main/java/seedu/address/storage/StorageManager.java rename to src/main/java/unicash/storage/StorageManager.java index 23a0f92cc9c..371ffa806bc 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/unicash/storage/StorageManager.java @@ -1,15 +1,15 @@ -package seedu.address.storage; +package unicash.storage; import java.io.IOException; import java.nio.file.Path; import java.util.Optional; import java.util.logging.Logger; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; +import unicash.commons.core.LogsCenter; +import unicash.commons.exceptions.DataLoadingException; +import unicash.model.ReadOnlyUniCash; +import unicash.model.ReadOnlyUserPrefs; +import unicash.model.UserPrefs; /** * Manages storage of UniCash data in local storage. diff --git a/src/main/java/seedu/address/storage/UniCashStorage.java b/src/main/java/unicash/storage/UniCashStorage.java similarity index 78% rename from src/main/java/seedu/address/storage/UniCashStorage.java rename to src/main/java/unicash/storage/UniCashStorage.java index ab366fdf481..fbacf28e97b 100644 --- a/src/main/java/seedu/address/storage/UniCashStorage.java +++ b/src/main/java/unicash/storage/UniCashStorage.java @@ -1,14 +1,15 @@ -package seedu.address.storage; +package unicash.storage; import java.io.IOException; import java.nio.file.Path; import java.util.Optional; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyUniCash; +import unicash.commons.exceptions.DataLoadingException; +import unicash.model.ReadOnlyUniCash; +import unicash.model.UniCash; /** - * Represents a storage for {@link seedu.address.model.UniCash}. + * Represents a storage for {@link UniCash}. */ public interface UniCashStorage { @@ -18,7 +19,7 @@ public interface UniCashStorage { Path getUniCashFilePath(); /** - * Returns UniCash data as a {@link seedu.address.model.ReadOnlyUniCash}. + * Returns UniCash data as a {@link ReadOnlyUniCash}. * Returns {@code Optional.empty()} if storage file is not found. * * @throws DataLoadingException if loading the data from storage failed. diff --git a/src/main/java/seedu/address/storage/UserPrefsStorage.java b/src/main/java/unicash/storage/UserPrefsStorage.java similarity index 69% rename from src/main/java/seedu/address/storage/UserPrefsStorage.java rename to src/main/java/unicash/storage/UserPrefsStorage.java index e94ca422ea8..701f1cf7f73 100644 --- a/src/main/java/seedu/address/storage/UserPrefsStorage.java +++ b/src/main/java/unicash/storage/UserPrefsStorage.java @@ -1,15 +1,15 @@ -package seedu.address.storage; +package unicash.storage; import java.io.IOException; import java.nio.file.Path; import java.util.Optional; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UserPrefs; +import unicash.commons.exceptions.DataLoadingException; +import unicash.model.ReadOnlyUserPrefs; +import unicash.model.UserPrefs; /** - * Represents a storage for {@link seedu.address.model.UserPrefs}. + * Represents a storage for {@link UserPrefs}. */ public interface UserPrefsStorage { @@ -27,7 +27,7 @@ public interface UserPrefsStorage { Optional readUserPrefs() throws DataLoadingException; /** - * Saves the given {@link seedu.address.model.ReadOnlyUserPrefs} to the storage. + * Saves the given {@link ReadOnlyUserPrefs} to the storage. * @param userPrefs cannot be null. * @throws IOException if there was any problem writing to the file. */ diff --git a/src/main/java/seedu/address/ui/CommandBox.java b/src/main/java/unicash/ui/CommandBox.java similarity index 89% rename from src/main/java/seedu/address/ui/CommandBox.java rename to src/main/java/unicash/ui/CommandBox.java index 9e75478664b..6c3f5df54ab 100644 --- a/src/main/java/seedu/address/ui/CommandBox.java +++ b/src/main/java/unicash/ui/CommandBox.java @@ -1,12 +1,13 @@ -package seedu.address.ui; +package unicash.ui; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.TextField; import javafx.scene.layout.Region; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.logic.commands.CommandResult; +import unicash.logic.commands.exceptions.CommandException; +import unicash.logic.parser.exceptions.ParseException; +import unicash.logic.Logic; /** * The UI component that is responsible for receiving user command inputs. @@ -77,7 +78,7 @@ public interface CommandExecutor { /** * Executes the command and returns the result. * - * @see seedu.address.logic.Logic#execute(String) + * @see Logic#execute(String) */ CommandResult execute(String commandText) throws CommandException, ParseException; } diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/unicash/ui/HelpWindow.java similarity index 97% rename from src/main/java/seedu/address/ui/HelpWindow.java rename to src/main/java/unicash/ui/HelpWindow.java index 2bb9f6eec92..90951c489ab 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/unicash/ui/HelpWindow.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import java.util.logging.Logger; @@ -8,7 +8,7 @@ import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; import javafx.stage.Stage; -import seedu.address.commons.core.LogsCenter; +import unicash.commons.core.LogsCenter; /** * Controller for a help page diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/unicash/ui/MainWindow.java similarity index 93% rename from src/main/java/seedu/address/ui/MainWindow.java rename to src/main/java/unicash/ui/MainWindow.java index c8c714bbd40..f7eff621ba1 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/unicash/ui/MainWindow.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import java.util.logging.Logger; @@ -10,12 +10,12 @@ import javafx.scene.input.KeyEvent; import javafx.scene.layout.StackPane; import javafx.stage.Stage; -import seedu.address.commons.core.GuiSettings; -import seedu.address.commons.core.LogsCenter; -import seedu.address.logic.Logic; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.commons.core.GuiSettings; +import unicash.commons.core.LogsCenter; +import unicash.logic.Logic; +import unicash.logic.commands.CommandResult; +import unicash.logic.commands.exceptions.CommandException; +import unicash.logic.parser.exceptions.ParseException; /** * The Main Window. Provides the basic application layout containing @@ -166,7 +166,7 @@ private void handleExit() { /** * Executes the command and returns the result. * - * @see seedu.address.logic.Logic#execute(String) + * @see Logic#execute(String) */ private CommandResult executeCommand(String commandText) throws CommandException, ParseException { try { diff --git a/src/main/java/seedu/address/ui/ResultDisplay.java b/src/main/java/unicash/ui/ResultDisplay.java similarity index 95% rename from src/main/java/seedu/address/ui/ResultDisplay.java rename to src/main/java/unicash/ui/ResultDisplay.java index 7d98e84eedf..2e0b772f528 100644 --- a/src/main/java/seedu/address/ui/ResultDisplay.java +++ b/src/main/java/unicash/ui/ResultDisplay.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import static java.util.Objects.requireNonNull; diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/unicash/ui/StatusBarFooter.java similarity index 96% rename from src/main/java/seedu/address/ui/StatusBarFooter.java rename to src/main/java/unicash/ui/StatusBarFooter.java index b577f829423..a97c09e60d0 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/unicash/ui/StatusBarFooter.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/src/main/java/seedu/address/ui/TransactionCard.java b/src/main/java/unicash/ui/TransactionCard.java similarity index 94% rename from src/main/java/seedu/address/ui/TransactionCard.java rename to src/main/java/unicash/ui/TransactionCard.java index c63970f996e..193448b725d 100644 --- a/src/main/java/seedu/address/ui/TransactionCard.java +++ b/src/main/java/unicash/ui/TransactionCard.java @@ -1,10 +1,10 @@ -package seedu.address.ui; +package unicash.ui; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import seedu.address.model.transaction.Transaction; +import unicash.model.transaction.Transaction; /** * A UI component that displays information of a {@code Transaction}. diff --git a/src/main/java/seedu/address/ui/TransactionListPanel.java b/src/main/java/unicash/ui/TransactionListPanel.java similarity index 92% rename from src/main/java/seedu/address/ui/TransactionListPanel.java rename to src/main/java/unicash/ui/TransactionListPanel.java index d0e673fdd9d..44b7f9cdb3d 100644 --- a/src/main/java/seedu/address/ui/TransactionListPanel.java +++ b/src/main/java/unicash/ui/TransactionListPanel.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import java.util.logging.Logger; @@ -7,8 +7,8 @@ import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.layout.Region; -import seedu.address.commons.core.LogsCenter; -import seedu.address.model.transaction.Transaction; +import unicash.commons.core.LogsCenter; +import unicash.model.transaction.Transaction; /** * Panel containing the list of persons. diff --git a/src/main/java/seedu/address/ui/Ui.java b/src/main/java/unicash/ui/Ui.java similarity index 86% rename from src/main/java/seedu/address/ui/Ui.java rename to src/main/java/unicash/ui/Ui.java index 17aa0b494fe..f51cb89ddeb 100644 --- a/src/main/java/seedu/address/ui/Ui.java +++ b/src/main/java/unicash/ui/Ui.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import javafx.stage.Stage; diff --git a/src/main/java/seedu/address/ui/UiManager.java b/src/main/java/unicash/ui/UiManager.java similarity index 94% rename from src/main/java/seedu/address/ui/UiManager.java rename to src/main/java/unicash/ui/UiManager.java index fdf024138bc..e6801fc3379 100644 --- a/src/main/java/seedu/address/ui/UiManager.java +++ b/src/main/java/unicash/ui/UiManager.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import java.util.logging.Logger; @@ -7,10 +7,10 @@ import javafx.scene.control.Alert.AlertType; import javafx.scene.image.Image; import javafx.stage.Stage; -import seedu.address.MainApp; -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.util.StringUtil; -import seedu.address.logic.Logic; +import unicash.MainApp; +import unicash.commons.core.LogsCenter; +import unicash.commons.util.StringUtil; +import unicash.logic.Logic; /** * The manager of the UI component. diff --git a/src/main/java/seedu/address/ui/UiPart.java b/src/main/java/unicash/ui/UiPart.java similarity index 97% rename from src/main/java/seedu/address/ui/UiPart.java rename to src/main/java/unicash/ui/UiPart.java index fc820e01a9c..ce9bcba59ee 100644 --- a/src/main/java/seedu/address/ui/UiPart.java +++ b/src/main/java/unicash/ui/UiPart.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import static java.util.Objects.requireNonNull; @@ -6,7 +6,7 @@ import java.net.URL; import javafx.fxml.FXMLLoader; -import seedu.address.MainApp; +import unicash.MainApp; /** * Represents a distinct part of the UI. e.g. Windows, dialogs, panels, status bars, etc. diff --git a/src/test/java/seedu/address/logic/commands/ExitCommandUniCashTest.java b/src/test/java/seedu/address/logic/commands/ExitCommandUniCashTest.java deleted file mode 100644 index 2dbb1931db3..00000000000 --- a/src/test/java/seedu/address/logic/commands/ExitCommandUniCashTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package seedu.address.logic.commands; - -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.ExitCommandUniCash.MESSAGE_EXIT_ACKNOWLEDGEMENT; - -import org.junit.jupiter.api.Test; - -import seedu.address.model.Model; -import seedu.address.model.ModelManager; - -public class ExitCommandUniCashTest { - - private Model model = new ModelManager(); - private Model expectedModel = new ModelManager(); - - @Test - public void execute_exit_success() { - CommandResult expectedCommandResult = - new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); - - assertCommandSuccess(new ExitCommandUniCash(), model, - expectedCommandResult, expectedModel); - } -} - diff --git a/src/test/java/seedu/address/model/transaction/TransactionTest.java b/src/test/java/seedu/address/model/transaction/TransactionTest.java deleted file mode 100644 index 73c0f74550f..00000000000 --- a/src/test/java/seedu/address/model/transaction/TransactionTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package seedu.address.model.transaction; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static seedu.address.testutil.TypicalTransactions.BUYING_GROCERIES; -import static seedu.address.testutil.TypicalTransactions.DINING_WITH_FRIENDS; -import static seedu.address.testutil.TypicalTransactions.WORK_AT_LIHO; - -import org.junit.jupiter.api.Test; - -import seedu.address.testutil.TransactionBuilder; - -public class TransactionTest { - - @Test - public void equals() { - // same values -> returns true - Transaction groceriesCopy = new TransactionBuilder(BUYING_GROCERIES).build(); - assertEquals(BUYING_GROCERIES, groceriesCopy); - - // same object -> returns true - assertEquals(BUYING_GROCERIES, BUYING_GROCERIES); - - // null -> returns false - assertNotEquals(null, groceriesCopy); - - // null -> returns false - assertNotEquals(null, BUYING_GROCERIES); - - // different type -> returns false - assertNotEquals(5, BUYING_GROCERIES); - - assertFalse(BUYING_GROCERIES.equals(5)); - - // different person -> returns false - assertNotEquals(BUYING_GROCERIES, DINING_WITH_FRIENDS); - - // different name -> returns false - Transaction editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withName("Another thing").build(); - assertNotEquals(BUYING_GROCERIES, editedGroceries); - - // different amount -> returns false - editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withAmount(10.15).build(); - assertNotEquals(BUYING_GROCERIES, editedGroceries); - - // different date -> returns false - editedGroceries = new TransactionBuilder(BUYING_GROCERIES) - .withDateTime("01-01-1999 18:18") - .build(); - assertNotEquals(BUYING_GROCERIES, editedGroceries); - - // different location -> returns false - editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withLocation("UTown").build(); - assertNotEquals(BUYING_GROCERIES, editedGroceries); - - // different transaction type -> return false - editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withType("expense").build(); - assertNotEquals(BUYING_GROCERIES, editedGroceries); - - // different categories -> returns false - editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withCategories("TEST").build(); - assertFalse(BUYING_GROCERIES.equals(editedGroceries)); - } - - @Test - public void toStringMethod() { - String expected = - Transaction.class.getCanonicalName() - + "{name=" + BUYING_GROCERIES.getName() - + ", type=" + BUYING_GROCERIES.getType() - + ", amount=" + BUYING_GROCERIES.getAmount() - + ", dateTime=" + BUYING_GROCERIES.getDateTime() - + ", location=" + BUYING_GROCERIES.getLocation() - + ", categories=" + BUYING_GROCERIES.getCategories() - + "}"; - assertEquals(expected, BUYING_GROCERIES.toString()); - } - - @Test - public void hashCode_test() { - assertEquals(BUYING_GROCERIES.hashCode(), BUYING_GROCERIES.hashCode()); - assertNotEquals(BUYING_GROCERIES.hashCode(), WORK_AT_LIHO.hashCode()); - } -} diff --git a/src/test/java/seedu/address/testutil/TransactionUtil.java b/src/test/java/seedu/address/testutil/TransactionUtil.java deleted file mode 100644 index b0abda78cab..00000000000 --- a/src/test/java/seedu/address/testutil/TransactionUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -package seedu.address.testutil; - -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; - -import java.util.Set; - -import seedu.address.logic.commands.AddTransactionCommand; -import seedu.address.logic.commands.EditTransactionCommand; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Transaction; - -/** - * A utility class for Transaction. - */ -public class TransactionUtil { - - /** - * Returns an add command string for adding the {@code transaction}. - */ - public static String getAddTransactionCommand(Transaction transaction) { - return AddTransactionCommand.COMMAND_WORD + " " + getTransactionDetails(transaction); - } - - /** - * Returns the part of command string for the given {@code transaction}'s details. - */ - public static String getTransactionDetails(Transaction transaction) { - StringBuilder sb = new StringBuilder(); - sb.append(PREFIX_NAME).append(transaction.getName().fullName).append(" "); - sb.append(PREFIX_TYPE).append(transaction.getType().type.getOriginalString()).append(" "); - sb.append(PREFIX_AMOUNT).append(transaction.getAmount().toString()).append(" "); - sb.append(PREFIX_DATETIME).append(transaction.getDateTime().originalString()).append(" "); - sb.append(PREFIX_LOCATION).append(transaction.getLocation().location).append(" "); - transaction.getCategories().forEach( - category -> sb.append(PREFIX_CATEGORY).append(category.category).append(" ") - ); - return sb.toString(); - } - - public static String getEditTransactionDescriptorDetails(EditTransactionCommand - .EditTransactionDescriptor descriptor) { - StringBuilder sb = new StringBuilder(); - descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName) - .append(" ")); - descriptor.getType().ifPresent(type -> sb.append(PREFIX_TYPE).append(type.type.getOriginalString()) - .append(" ")); - descriptor.getAmount().ifPresent(amount -> sb.append(PREFIX_AMOUNT).append(amount.amount) - .append(" ")); - descriptor.getLocation().ifPresent(location -> sb.append(PREFIX_LOCATION).append(location) - .append(" ")); - descriptor.getDateTime().ifPresent(dateTime -> sb.append(PREFIX_DATETIME).append(dateTime.originalString()) - .append(" ")); - if (descriptor.getCategories().isPresent()) { - Set categories = descriptor.getCategories().get(); - if (categories.isEmpty()) { - sb.append(PREFIX_CATEGORY); - } else { - categories.forEach(s -> sb.append(PREFIX_CATEGORY).append(s.category).append(" ")); - } - } - return sb.toString(); - } -} diff --git a/src/test/java/seedu/address/testutil/TypicalTransactions.java b/src/test/java/seedu/address/testutil/TypicalTransactions.java deleted file mode 100644 index 76912e221cd..00000000000 --- a/src/test/java/seedu/address/testutil/TypicalTransactions.java +++ /dev/null @@ -1,89 +0,0 @@ -package seedu.address.testutil; - -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_SHOPPING; -import static seedu.address.logic.commands.CommandTestUtil.VALID_CATEGORY_EDUCATION; -import static seedu.address.logic.commands.CommandTestUtil.VALID_CATEGORY_ENTERTAINMENT; -import static seedu.address.logic.commands.CommandTestUtil.VALID_CATEGORY_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_DATETIME_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.VALID_DATETIME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_DATETIME_SHOPPING; -import static seedu.address.logic.commands.CommandTestUtil.VALID_LOCATION_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_LOCATION_ORCHARD; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_SHOPPING; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TYPE_EXPENSE; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TYPE_INCOME; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import seedu.address.model.UniCash; -import seedu.address.model.transaction.Transaction; - -/** - * A utility class containing a list of {@code Transaction} objects to be used in tests. - */ -public class TypicalTransactions { - public static final Transaction BUYING_GROCERIES = new TransactionBuilder() - .withName("Buying groceries") - .withAmount(16.75) - .withLocation("Sheng Shiong (UTown)") - .withCategories("Groceries") - .build(); - - public static final Transaction DINING_WITH_FRIENDS = new TransactionBuilder() - .withName("End of Semester Celebration") - .withAmount(234.50) - .withLocation("Poulet") - .withDateTime("18-08-2001 18:18") - .withCategories("Food") - .build(); - - public static final Transaction WORK_AT_LIHO = new TransactionBuilder() - .withName("Working at liho") - .withType("income") - .withAmount(888) - .withDateTime("18-09-2002 18:17") - .build(); - - // Manually added - Income's details found in {@code CommandTestUtil} - public static final Transaction NUS = new TransactionBuilder().withName(VALID_TRANSACTION_NAME_NUS) - .withType(VALID_TYPE_EXPENSE) - .withAmount(VALID_AMOUNT_NUS) - .withDateTime(VALID_DATETIME_NUS) - .withLocation(VALID_LOCATION_NUS) - .withCategories(VALID_CATEGORY_NUS) - .build(); - public static final Transaction INTERN = new TransactionBuilder().withName(VALID_TRANSACTION_NAME_INTERN) - .withType(VALID_TYPE_EXPENSE) - .withAmount(VALID_AMOUNT_INTERN) - .withDateTime(VALID_DATETIME_INTERN) - .withLocation(VALID_LOCATION_ORCHARD) - .build(); - - public static final Transaction SHOPPING = new TransactionBuilder().withName(VALID_TRANSACTION_NAME_SHOPPING) - .withType(VALID_TYPE_INCOME) - .withAmount(VALID_AMOUNT_SHOPPING) - .withDateTime(VALID_DATETIME_SHOPPING) - .withLocation(VALID_LOCATION_ORCHARD) - .withCategories(VALID_CATEGORY_ENTERTAINMENT, VALID_CATEGORY_EDUCATION) - .build(); - /** - * Returns a {@code UniCash} with all the typical transactions. - */ - public static UniCash getTypicalUniCash() { - UniCash ab = new UniCash(); - for (Transaction transaction : getTypicalTransactions()) { - ab.addTransaction(transaction); - } - return ab; - } - - public static List getTypicalTransactions() { - return new ArrayList<>(Arrays.asList(BUYING_GROCERIES, DINING_WITH_FRIENDS, WORK_AT_LIHO, NUS, INTERN)); - } -} diff --git a/src/test/java/seedu/address/AppParametersTest.java b/src/test/java/unicash/AppParametersTest.java similarity index 99% rename from src/test/java/seedu/address/AppParametersTest.java rename to src/test/java/unicash/AppParametersTest.java index 2257530f2a3..a9fe1a45f96 100644 --- a/src/test/java/seedu/address/AppParametersTest.java +++ b/src/test/java/unicash/AppParametersTest.java @@ -1,4 +1,4 @@ -package seedu.address; +package unicash; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/seedu/address/commons/core/ConfigTest.java b/src/test/java/unicash/commons/core/ConfigTest.java similarity index 97% rename from src/test/java/seedu/address/commons/core/ConfigTest.java rename to src/test/java/unicash/commons/core/ConfigTest.java index 2709c4396ce..f5dc9217b8a 100644 --- a/src/test/java/seedu/address/commons/core/ConfigTest.java +++ b/src/test/java/unicash/commons/core/ConfigTest.java @@ -1,4 +1,4 @@ -package seedu.address.commons.core; +package unicash.commons.core; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/seedu/address/commons/core/GuiSettingsTest.java b/src/test/java/unicash/commons/core/GuiSettingsTest.java similarity index 98% rename from src/test/java/seedu/address/commons/core/GuiSettingsTest.java rename to src/test/java/unicash/commons/core/GuiSettingsTest.java index 72fbbaa733c..af07baf048a 100644 --- a/src/test/java/seedu/address/commons/core/GuiSettingsTest.java +++ b/src/test/java/unicash/commons/core/GuiSettingsTest.java @@ -1,4 +1,4 @@ -package seedu.address.commons.core; +package unicash.commons.core; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/seedu/address/commons/core/VersionTest.java b/src/test/java/unicash/commons/core/VersionTest.java similarity index 96% rename from src/test/java/seedu/address/commons/core/VersionTest.java rename to src/test/java/unicash/commons/core/VersionTest.java index 837c23be550..84b4049a178 100644 --- a/src/test/java/seedu/address/commons/core/VersionTest.java +++ b/src/test/java/unicash/commons/core/VersionTest.java @@ -1,12 +1,13 @@ -package seedu.address.commons.core; +package unicash.commons.core; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class VersionTest { @@ -19,7 +20,7 @@ public void versionParsing_acceptableVersionString_parsedVersionCorrectly() { @Test public void versionParsing_wrongVersionString_throwIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> Version.fromString("This is not a version string")); + Assert.assertThrows(IllegalArgumentException.class, () -> Version.fromString("This is not a version string")); } @Test diff --git a/src/test/java/seedu/address/commons/core/index/IndexTest.java b/src/test/java/unicash/commons/core/index/IndexTest.java similarity index 87% rename from src/test/java/seedu/address/commons/core/index/IndexTest.java rename to src/test/java/unicash/commons/core/index/IndexTest.java index deb3a3b0250..c10e36df935 100644 --- a/src/test/java/seedu/address/commons/core/index/IndexTest.java +++ b/src/test/java/unicash/commons/core/index/IndexTest.java @@ -1,18 +1,19 @@ -package seedu.address.commons.core.index; +package unicash.commons.core.index; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class IndexTest { @Test public void createOneBasedIndex() { // invalid index - assertThrows(IndexOutOfBoundsException.class, () -> Index.fromOneBased(0)); + Assert.assertThrows(IndexOutOfBoundsException.class, () -> Index.fromOneBased(0)); // check equality using the same base assertEquals(1, Index.fromOneBased(1).getOneBased()); @@ -26,7 +27,7 @@ public void createOneBasedIndex() { @Test public void createZeroBasedIndex() { // invalid index - assertThrows(IndexOutOfBoundsException.class, () -> Index.fromZeroBased(-1)); + Assert.assertThrows(IndexOutOfBoundsException.class, () -> Index.fromZeroBased(-1)); // check equality using the same base assertEquals(0, Index.fromZeroBased(0).getZeroBased()); diff --git a/src/test/java/seedu/address/commons/util/AppUtilTest.java b/src/test/java/unicash/commons/util/AppUtilTest.java similarity index 63% rename from src/test/java/seedu/address/commons/util/AppUtilTest.java rename to src/test/java/unicash/commons/util/AppUtilTest.java index 594de1e6365..33f43c9232b 100644 --- a/src/test/java/seedu/address/commons/util/AppUtilTest.java +++ b/src/test/java/unicash/commons/util/AppUtilTest.java @@ -1,9 +1,10 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class AppUtilTest { @@ -14,7 +15,7 @@ public void getImage_exitingImage() { @Test public void getImage_nullGiven_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> AppUtil.getImage(null)); + Assert.assertThrows(NullPointerException.class, () -> AppUtil.getImage(null)); } @Test @@ -25,12 +26,12 @@ public void checkArgument_true_nothingHappens() { @Test public void checkArgument_falseWithoutErrorMessage_throwsIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> AppUtil.checkArgument(false)); + Assert.assertThrows(IllegalArgumentException.class, () -> AppUtil.checkArgument(false)); } @Test public void checkArgument_falseWithErrorMessage_throwsIllegalArgumentException() { String errorMessage = "error message"; - assertThrows(IllegalArgumentException.class, errorMessage, () -> AppUtil.checkArgument(false, errorMessage)); + Assert.assertThrows(IllegalArgumentException.class, errorMessage, () -> AppUtil.checkArgument(false, errorMessage)); } } diff --git a/src/test/java/seedu/address/commons/util/CollectionUtilTest.java b/src/test/java/unicash/commons/util/CollectionUtilTest.java similarity index 89% rename from src/test/java/seedu/address/commons/util/CollectionUtilTest.java rename to src/test/java/unicash/commons/util/CollectionUtilTest.java index 2c21d11b040..3da5b3facf7 100644 --- a/src/test/java/seedu/address/commons/util/CollectionUtilTest.java +++ b/src/test/java/unicash/commons/util/CollectionUtilTest.java @@ -1,9 +1,9 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.commons.util.CollectionUtil.requireAllNonNull; +import static unicash.testutil.Assert.assertThrows; import java.util.Arrays; import java.util.Collection; @@ -11,6 +11,7 @@ import java.util.List; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class CollectionUtilTest { @Test @@ -87,7 +88,7 @@ public void isAnyNonNull() { * if {@code objects} or any element of {@code objects} is null. */ private void assertNullPointerExceptionThrown(Object... objects) { - assertThrows(NullPointerException.class, () -> requireAllNonNull(objects)); + Assert.assertThrows(NullPointerException.class, () -> CollectionUtil.requireAllNonNull(objects)); } /** @@ -95,14 +96,14 @@ private void assertNullPointerExceptionThrown(Object... objects) { * if {@code collection} or any element of {@code collection} is null. */ private void assertNullPointerExceptionThrown(Collection collection) { - assertThrows(NullPointerException.class, () -> requireAllNonNull(collection)); + Assert.assertThrows(NullPointerException.class, () -> CollectionUtil.requireAllNonNull(collection)); } private void assertNullPointerExceptionNotThrown(Object... objects) { - requireAllNonNull(objects); + CollectionUtil.requireAllNonNull(objects); } private void assertNullPointerExceptionNotThrown(Collection collection) { - requireAllNonNull(collection); + CollectionUtil.requireAllNonNull(collection); } } diff --git a/src/test/java/seedu/address/commons/util/ConfigUtilTest.java b/src/test/java/unicash/commons/util/ConfigUtilTest.java similarity index 85% rename from src/test/java/seedu/address/commons/util/ConfigUtilTest.java rename to src/test/java/unicash/commons/util/ConfigUtilTest.java index 69d7b89cfd8..afcff984d1d 100644 --- a/src/test/java/seedu/address/commons/util/ConfigUtilTest.java +++ b/src/test/java/unicash/commons/util/ConfigUtilTest.java @@ -1,8 +1,8 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.io.IOException; import java.nio.file.Path; @@ -13,8 +13,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.commons.core.Config; -import seedu.address.commons.exceptions.DataLoadingException; +import unicash.commons.core.Config; +import unicash.commons.exceptions.DataLoadingException; +import unicash.testutil.Assert; public class ConfigUtilTest { @@ -25,7 +26,7 @@ public class ConfigUtilTest { @Test public void read_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> read(null)); + Assert.assertThrows(NullPointerException.class, () -> read(null)); } @Test @@ -35,7 +36,7 @@ public void read_missingFile_emptyResult() throws DataLoadingException { @Test public void read_notJsonFormat_exceptionThrown() { - assertThrows(DataLoadingException.class, () -> read("NotJsonFormatConfig.json")); + Assert.assertThrows(DataLoadingException.class, () -> read("NotJsonFormatConfig.json")); } @Test @@ -75,12 +76,12 @@ private Optional read(String configFileInTestDataFolder) throws DataLoad @Test public void save_nullConfig_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> save(null, "SomeFile.json")); + Assert.assertThrows(NullPointerException.class, () -> save(null, "SomeFile.json")); } @Test public void save_nullFile_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> save(new Config(), null)); + Assert.assertThrows(NullPointerException.class, () -> save(new Config(), null)); } @Test diff --git a/src/test/java/seedu/address/commons/util/FileUtilTest.java b/src/test/java/unicash/commons/util/FileUtilTest.java similarity index 82% rename from src/test/java/seedu/address/commons/util/FileUtilTest.java rename to src/test/java/unicash/commons/util/FileUtilTest.java index 913209a7c4e..8e9cb82e77c 100644 --- a/src/test/java/seedu/address/commons/util/FileUtilTest.java +++ b/src/test/java/unicash/commons/util/FileUtilTest.java @@ -1,8 +1,8 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.io.IOException; import java.nio.file.Files; @@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import unicash.testutil.Assert; public class FileUtilTest { @@ -25,7 +26,7 @@ public void isValidPath() { assertFalse(FileUtil.isValidPath("a\0")); // null path -> throws NullPointerException - assertThrows(NullPointerException.class, () -> FileUtil.isValidPath(null)); + Assert.assertThrows(NullPointerException.class, () -> FileUtil.isValidPath(null)); } @Test diff --git a/src/test/java/seedu/address/commons/util/JsonUtilTest.java b/src/test/java/unicash/commons/util/JsonUtilTest.java similarity index 92% rename from src/test/java/seedu/address/commons/util/JsonUtilTest.java rename to src/test/java/unicash/commons/util/JsonUtilTest.java index 3f8688a9d6e..7e615d65a95 100644 --- a/src/test/java/seedu/address/commons/util/JsonUtilTest.java +++ b/src/test/java/unicash/commons/util/JsonUtilTest.java @@ -1,4 +1,4 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -7,8 +7,8 @@ import org.junit.jupiter.api.Test; -import seedu.address.testutil.SerializableTestClass; -import seedu.address.testutil.TestUtil; +import unicash.testutil.SerializableTestClass; +import unicash.testutil.TestUtil; /** * Tests JSON Read and Write diff --git a/src/test/java/seedu/address/commons/util/StringUtilTest.java b/src/test/java/unicash/commons/util/StringUtilTest.java similarity index 88% rename from src/test/java/seedu/address/commons/util/StringUtilTest.java rename to src/test/java/unicash/commons/util/StringUtilTest.java index c56d407bf3f..936ec6fabb8 100644 --- a/src/test/java/seedu/address/commons/util/StringUtilTest.java +++ b/src/test/java/unicash/commons/util/StringUtilTest.java @@ -1,12 +1,13 @@ -package seedu.address.commons.util; +package unicash.commons.util; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.io.FileNotFoundException; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class StringUtilTest { @@ -56,24 +57,24 @@ public void isNonZeroUnsignedInteger() { @Test public void containsWordIgnoreCase_nullWord_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase("typical sentence", null)); + Assert.assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase("typical sentence", null)); } @Test public void containsWordIgnoreCase_emptyWord_throwsIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, "Word parameter cannot be empty", () + Assert.assertThrows(IllegalArgumentException.class, "Word parameter cannot be empty", () -> StringUtil.containsWordIgnoreCase("typical sentence", " ")); } @Test public void containsWordIgnoreCase_multipleWords_throwsIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, "Word parameter should be a single word", () + Assert.assertThrows(IllegalArgumentException.class, "Word parameter should be a single word", () -> StringUtil.containsWordIgnoreCase("typical sentence", "aaa BBB")); } @Test public void containsWordIgnoreCase_nullSentence_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase(null, "abc")); + Assert.assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase(null, "abc")); } /* @@ -137,7 +138,7 @@ public void getDetails_exceptionGiven() { @Test public void getDetails_nullGiven_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> StringUtil.getDetails(null)); + Assert.assertThrows(NullPointerException.class, () -> StringUtil.getDetails(null)); } } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/unicash/logic/LogicManagerTest.java similarity index 76% rename from src/test/java/seedu/address/logic/LogicManagerTest.java rename to src/test/java/unicash/logic/LogicManagerTest.java index a4fcf189c67..681bf630784 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/unicash/logic/LogicManagerTest.java @@ -1,41 +1,38 @@ -package seedu.address.logic; +package unicash.logic; import static org.junit.jupiter.api.Assertions.assertEquals; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX; -import static seedu.address.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; -import static seedu.address.logic.commands.CommandTestUtil.AMOUNT_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.CATEGORY_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.LOCATION_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.TYPE_DESC_EXPENSE; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.NUS; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX; +import static unicash.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; +import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.NUS; import java.io.IOException; import java.nio.file.AccessDeniedException; import java.nio.file.Path; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.commons.core.GuiSettings; -import seedu.address.logic.commands.AddTransactionCommand; -import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.ListCommand; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; -import seedu.address.model.transaction.Transaction; -import seedu.address.storage.JsonUniCashStorage; -import seedu.address.storage.JsonUserPrefsStorage; -import seedu.address.storage.StorageManager; -import seedu.address.testutil.TransactionBuilder; +import unicash.commons.core.GuiSettings; +import unicash.logic.commands.AddTransactionCommand; +import unicash.logic.commands.CommandResult; +import unicash.logic.commands.ListCommand; +import unicash.logic.commands.exceptions.CommandException; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.ReadOnlyUniCash; +import unicash.model.UniCash; +import unicash.model.UserPrefs; +import unicash.model.transaction.Transaction; +import unicash.storage.JsonUniCashStorage; +import unicash.storage.JsonUserPrefsStorage; +import unicash.storage.StorageManager; +import unicash.testutil.TransactionBuilder; +import unicash.logic.commands.CommandTestUtil; +import unicash.testutil.Assert; public class LogicManagerTest { private static final IOException DUMMY_IO_EXCEPTION = new IOException("dummy IO exception"); @@ -88,12 +85,12 @@ public void execute_storageThrowsAdException_throwsCommandException() { @Test public void getFilteredTransactionList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredTransactionList().remove(0)); + Assert.assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredTransactionList().remove(0)); } @Test public void getGuiSettings() { - assertEquals(model.getGuiSettings(), new GuiSettings()); + Assertions.assertEquals(model.getGuiSettings(), new GuiSettings()); } @Test @@ -158,7 +155,7 @@ private void assertCommandFailure(String inputCommand, Class expectedException, String expectedMessage, Model expectedModel) { - assertThrows(expectedException, expectedMessage, () -> logic.execute(inputCommand)); + Assert.assertThrows(expectedException, expectedMessage, () -> logic.execute(inputCommand)); assertEquals(expectedModel, model); } @@ -188,12 +185,12 @@ public void saveUniCash(ReadOnlyUniCash uniCash, Path filePath) // Triggers the saveUniCash method by executing an add command String addCommand = AddTransactionCommand.COMMAND_WORD - + TRANSACTION_NAME_DESC_NUS - + CATEGORY_DESC_NUS - + AMOUNT_DESC_NUS - + DATETIME_DESC_NUS - + TYPE_DESC_EXPENSE - + LOCATION_DESC_NUS; + + CommandTestUtil.TRANSACTION_NAME_DESC_NUS + + CommandTestUtil.CATEGORY_DESC_NUS + + CommandTestUtil.AMOUNT_DESC_NUS + + CommandTestUtil.DATETIME_DESC_NUS + + CommandTestUtil.TYPE_DESC_EXPENSE + + CommandTestUtil.LOCATION_DESC_NUS; Transaction expectedTransaction = new TransactionBuilder(NUS).build(); ModelManager expectedModel = new ModelManager(); expectedModel.addTransaction(expectedTransaction); diff --git a/src/test/java/seedu/address/logic/UniCashMessagesTest.java b/src/test/java/unicash/logic/UniCashMessagesTest.java similarity index 94% rename from src/test/java/seedu/address/logic/UniCashMessagesTest.java rename to src/test/java/unicash/logic/UniCashMessagesTest.java index ac98ab7e593..7525fc3901f 100644 --- a/src/test/java/seedu/address/logic/UniCashMessagesTest.java +++ b/src/test/java/unicash/logic/UniCashMessagesTest.java @@ -1,11 +1,11 @@ -package seedu.address.logic; +package unicash.logic; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import seedu.address.logic.parser.Prefix; +import unicash.logic.parser.Prefix; public class UniCashMessagesTest { diff --git a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java b/src/test/java/unicash/logic/commands/AddCommandIntegrationTest.java similarity index 78% rename from src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java rename to src/test/java/unicash/logic/commands/AddCommandIntegrationTest.java index 4f3e2877ce8..034ff83b698 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/unicash/logic/commands/AddCommandIntegrationTest.java @@ -1,16 +1,16 @@ //package seedu.address.logic.commands; -//import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; -//import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +//import static commands.logic.unicash.CommandTestUtil.assertCommandFailure; +//import static commands.logic.unicash.CommandTestUtil.assertCommandSuccess; // //import org.junit.jupiter.api.BeforeEach; //import org.junit.jupiter.api.Test; // -//import seedu.address.logic.UniCashMessages; -//import seedu.address.model.Model; -//import seedu.address.model.ModelManager; -//import seedu.address.model.UniCash; -//import seedu.address.model.UserPrefs; +//import logic.unicash.UniCashMessages; +//import model.unicash.Model; +//import model.unicash.ModelManager; +//import model.unicash.UniCash; +//import model.unicash.UserPrefs; //import seedu.address.model.person.Person; //import seedu.address.testutil.PersonBuilder; diff --git a/src/test/java/seedu/address/logic/commands/AddTransactionCommandTest.java b/src/test/java/unicash/logic/commands/AddTransactionCommandTest.java similarity index 91% rename from src/test/java/seedu/address/logic/commands/AddTransactionCommandTest.java rename to src/test/java/unicash/logic/commands/AddTransactionCommandTest.java index ff64053904d..649290a4f94 100644 --- a/src/test/java/seedu/address/logic/commands/AddTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/AddTransactionCommandTest.java @@ -1,12 +1,11 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static java.util.Objects.requireNonNull; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.NUS; +import static unicash.testutil.Assert.assertThrows; import java.nio.file.Path; import java.util.ArrayList; @@ -16,20 +15,22 @@ import org.junit.jupiter.api.Test; import javafx.collections.ObservableList; -import seedu.address.commons.core.GuiSettings; -import seedu.address.logic.UniCashMessages; -import seedu.address.model.Model; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.UniCash; -import seedu.address.model.transaction.Transaction; -import seedu.address.testutil.TransactionBuilder; +import unicash.commons.core.GuiSettings; +import unicash.logic.UniCashMessages; +import unicash.model.Model; +import unicash.model.ReadOnlyUniCash; +import unicash.model.ReadOnlyUserPrefs; +import unicash.model.UniCash; +import unicash.model.transaction.Transaction; +import unicash.testutil.TransactionBuilder; +import unicash.testutil.Assert; +import unicash.testutil.TypicalTransactions; public class AddTransactionCommandTest { @Test public void constructor_nullTransaction_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new AddTransactionCommand(null)); + Assert.assertThrows(NullPointerException.class, () -> new AddTransactionCommand(null)); } @Test @@ -82,8 +83,8 @@ public void equals() { @Test public void toStringMethod() { - AddTransactionCommand addTransactionCommand = new AddTransactionCommand(NUS); - String expected = AddTransactionCommand.class.getCanonicalName() + "{toAdd=" + NUS + "}"; + AddTransactionCommand addTransactionCommand = new AddTransactionCommand(TypicalTransactions.NUS); + String expected = AddTransactionCommand.class.getCanonicalName() + "{toAdd=" + TypicalTransactions.NUS + "}"; assertEquals(expected, addTransactionCommand.toString()); } diff --git a/src/test/java/seedu/address/logic/commands/ClearTransactionsCommandTest.java b/src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java similarity index 51% rename from src/test/java/seedu/address/logic/commands/ClearTransactionsCommandTest.java rename to src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java index 2f26fadced2..13826f62ea9 100644 --- a/src/test/java/seedu/address/logic/commands/ClearTransactionsCommandTest.java +++ b/src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java @@ -1,14 +1,14 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.testutil.TypicalTransactions.getTypicalUniCash; +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; import org.junit.jupiter.api.Test; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.UniCash; +import unicash.model.UserPrefs; +import unicash.testutil.TypicalTransactions; public class ClearTransactionsCommandTest { @@ -17,17 +17,17 @@ public void execute_emptyAddressBook_success() { Model model = new ModelManager(); Model expectedModel = new ModelManager(); - assertCommandSuccess(new ClearTransactionsCommand(), model, + CommandTestUtil.assertCommandSuccess(new ClearTransactionsCommand(), model, ClearTransactionsCommand.MESSAGE_SUCCESS, expectedModel); } @Test public void execute_nonEmptyUniCash_success() { - Model model = new ModelManager(getTypicalUniCash(), new UserPrefs()); + Model model = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); Model expectedModel = new ModelManager(new UniCash(), new UserPrefs()); expectedModel.setUniCash(new UniCash()); - assertCommandSuccess(new ClearTransactionsCommand(), model, + CommandTestUtil.assertCommandSuccess(new ClearTransactionsCommand(), model, ClearTransactionsCommand.MESSAGE_SUCCESS, expectedModel); } diff --git a/src/test/java/seedu/address/logic/commands/CommandResultTest.java b/src/test/java/unicash/logic/commands/CommandResultTest.java similarity index 98% rename from src/test/java/seedu/address/logic/commands/CommandResultTest.java rename to src/test/java/unicash/logic/commands/CommandResultTest.java index d6a59aa147f..ed3c6294630 100644 --- a/src/test/java/seedu/address/logic/commands/CommandResultTest.java +++ b/src/test/java/unicash/logic/commands/CommandResultTest.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/unicash/logic/commands/CommandTestUtil.java similarity index 68% rename from src/test/java/seedu/address/logic/commands/CommandTestUtil.java rename to src/test/java/unicash/logic/commands/CommandTestUtil.java index f477dcdea74..9dc113f5917 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/unicash/logic/commands/CommandTestUtil.java @@ -1,26 +1,22 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.UniCash; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.TransactionNameContainsKeywordsPredicate; -import seedu.address.testutil.EditTransactionDescriptorBuilder; +import unicash.commons.core.index.Index; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; +import unicash.model.UniCash; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; +import unicash.testutil.EditTransactionDescriptorBuilder; +import unicash.logic.parser.CliSyntax; +import unicash.testutil.Assert; /** * Contains helper methods for testing commands. @@ -44,25 +40,25 @@ public class CommandTestUtil { public static final String VALID_LOCATION_ORCHARD = "orchard"; public static final String VALID_LOCATION_NUS = "NUS"; - public static final String TRANSACTION_NAME_DESC_NUS = " " + PREFIX_NAME + VALID_TRANSACTION_NAME_NUS; - public static final String TRANSACTION_NAME_DESC_INTERN = " " + PREFIX_NAME + VALID_TRANSACTION_NAME_INTERN; - public static final String AMOUNT_DESC_NUS = " " + PREFIX_AMOUNT + VALID_AMOUNT_NUS; - public static final String AMOUNT_DESC_INTERN = " " + PREFIX_AMOUNT + VALID_AMOUNT_INTERN; - public static final String DATETIME_DESC_NUS = " " + PREFIX_DATETIME + VALID_DATETIME_NUS; - public static final String DATETIME_DESC_INTERN = " " + PREFIX_DATETIME + VALID_DATETIME_INTERN; - public static final String TYPE_DESC_EXPENSE = " " + PREFIX_TYPE + VALID_TYPE_EXPENSE; - public static final String TYPE_DESC_INCOME = " " + PREFIX_TYPE + VALID_TYPE_INCOME; - public static final String CATEGORY_DESC_ENTERTAINMENT = " " + PREFIX_CATEGORY + VALID_CATEGORY_ENTERTAINMENT; - public static final String CATEGORY_DESC_NUS = " " + PREFIX_CATEGORY + VALID_CATEGORY_NUS; - public static final String LOCATION_DESC_ORCHARD = " " + PREFIX_LOCATION + VALID_LOCATION_ORCHARD; - public static final String LOCATION_DESC_NUS = " " + PREFIX_LOCATION + VALID_LOCATION_NUS; - - public static final String INVALID_TRANSACTION_NAME_DESC = " " + PREFIX_NAME + "NUS&"; // '&' not allowed in names - public static final String INVALID_AMOUNT_DESC = " " + PREFIX_AMOUNT + "-3.0"; // negative amounts not allowed - public static final String INVALID_DATETIME_DESC = " " + PREFIX_DATETIME + "19/13/2001 19:30"; // invalid date - public static final String INVALID_TYPE_DESC = " " + PREFIX_TYPE + "afaf"; // invalid type - public static final String INVALID_CATEGORY_DESC = " " + PREFIX_CATEGORY + "afraf*&"; // invalid type - public static final String INVALID_LOCATION_DESC = " " + PREFIX_LOCATION + "a214faf*&"; // invalid type + public static final String TRANSACTION_NAME_DESC_NUS = " " + CliSyntax.PREFIX_NAME + VALID_TRANSACTION_NAME_NUS; + public static final String TRANSACTION_NAME_DESC_INTERN = " " + CliSyntax.PREFIX_NAME + VALID_TRANSACTION_NAME_INTERN; + public static final String AMOUNT_DESC_NUS = " " + CliSyntax.PREFIX_AMOUNT + VALID_AMOUNT_NUS; + public static final String AMOUNT_DESC_INTERN = " " + CliSyntax.PREFIX_AMOUNT + VALID_AMOUNT_INTERN; + public static final String DATETIME_DESC_NUS = " " + CliSyntax.PREFIX_DATETIME + VALID_DATETIME_NUS; + public static final String DATETIME_DESC_INTERN = " " + CliSyntax.PREFIX_DATETIME + VALID_DATETIME_INTERN; + public static final String TYPE_DESC_EXPENSE = " " + CliSyntax.PREFIX_TYPE + VALID_TYPE_EXPENSE; + public static final String TYPE_DESC_INCOME = " " + CliSyntax.PREFIX_TYPE + VALID_TYPE_INCOME; + public static final String CATEGORY_DESC_ENTERTAINMENT = " " + CliSyntax.PREFIX_CATEGORY + VALID_CATEGORY_ENTERTAINMENT; + public static final String CATEGORY_DESC_NUS = " " + CliSyntax.PREFIX_CATEGORY + VALID_CATEGORY_NUS; + public static final String LOCATION_DESC_ORCHARD = " " + CliSyntax.PREFIX_LOCATION + VALID_LOCATION_ORCHARD; + public static final String LOCATION_DESC_NUS = " " + CliSyntax.PREFIX_LOCATION + VALID_LOCATION_NUS; + + public static final String INVALID_TRANSACTION_NAME_DESC = " " + CliSyntax.PREFIX_NAME + "NUS&"; // '&' not allowed in names + public static final String INVALID_AMOUNT_DESC = " " + CliSyntax.PREFIX_AMOUNT + "-3.0"; // negative amounts not allowed + public static final String INVALID_DATETIME_DESC = " " + CliSyntax.PREFIX_DATETIME + "19/13/2001 19:30"; // invalid date + public static final String INVALID_TYPE_DESC = " " + CliSyntax.PREFIX_TYPE + "afaf"; // invalid type + public static final String INVALID_CATEGORY_DESC = " " + CliSyntax.PREFIX_CATEGORY + "afraf*&"; // invalid type + public static final String INVALID_LOCATION_DESC = " " + CliSyntax.PREFIX_LOCATION + "a214faf*&"; // invalid type public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble"; @@ -131,7 +127,7 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri UniCash expectedUniCash = new UniCash(actualModel.getUniCash()); List expectedFilteredList = new ArrayList<>(actualModel.getFilteredTransactionList()); - assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); + Assert.assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedUniCash, actualModel.getUniCash()); assertEquals(expectedFilteredList, actualModel.getFilteredTransactionList()); } diff --git a/src/test/java/seedu/address/logic/commands/DeleteTransactionCommandTest.java b/src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java similarity index 63% rename from src/test/java/seedu/address/logic/commands/DeleteTransactionCommandTest.java rename to src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java index baa573f8ea9..2d7f88dbfe1 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java @@ -1,24 +1,21 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showTransactionAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_TRANSACTION; -import static seedu.address.testutil.TypicalTransactions.getTypicalUniCash; +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; import org.junit.jupiter.api.Test; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.UniCashMessages; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UserPrefs; -import seedu.address.model.transaction.Transaction; +import unicash.commons.core.index.Index; +import unicash.logic.UniCashMessages; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.UserPrefs; +import unicash.model.transaction.Transaction; +import unicash.testutil.TypicalIndexes; +import unicash.testutil.TypicalTransactions; /** * Contains integration tests (interaction with the Model) and unit tests for @@ -26,27 +23,27 @@ */ public class DeleteTransactionCommandTest { - private final Model model = new ModelManager(getTypicalUniCash(), new UserPrefs()); + private final Model model = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); @Test public void execute_invalidIndexUnfilteredList_throwsCommandException() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredTransactionList().size() + 1); DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); + CommandTestUtil.assertCommandFailure(deleteCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } @Test public void equals() { - DeleteTransactionCommand deleteFirstCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); - DeleteTransactionCommand deleteSecondCommand = new DeleteTransactionCommand(INDEX_SECOND_TRANSACTION); + DeleteTransactionCommand deleteFirstCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); + DeleteTransactionCommand deleteSecondCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_SECOND_TRANSACTION); // same object -> returns true assertEquals(deleteFirstCommand, deleteFirstCommand); // same values -> returns true DeleteTransactionCommand deleteFirstCommandCopy = - new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); + new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); assertEquals(deleteFirstCommand, deleteFirstCommandCopy); // different types -> returns false @@ -73,47 +70,47 @@ public void toStringMethod() { @Test public void execute_validIndexUnfilteredList_success() { Transaction transactionToDelete = model.getFilteredTransactionList().get( - INDEX_FIRST_TRANSACTION.getZeroBased()); - DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); + TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); + DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); String expectedMessage = String.format(DeleteTransactionCommand.MESSAGE_DELETE_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(transactionToDelete)); - ModelManager expectedModel = new ModelManager(getTypicalUniCash(), new UserPrefs()); + ModelManager expectedModel = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); expectedModel.deleteTransaction(transactionToDelete); - assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); + CommandTestUtil.assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_validIndexFilteredList_success() { - showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); + CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); Transaction transactionToDelete = model.getFilteredTransactionList() - .get(INDEX_FIRST_TRANSACTION.getZeroBased()); - DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); + .get(TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); + DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); String expectedMessage = String.format(DeleteTransactionCommand.MESSAGE_DELETE_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(transactionToDelete)); - Model expectedModel = new ModelManager(getTypicalUniCash(), new UserPrefs()); + Model expectedModel = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); expectedModel.deleteTransaction(transactionToDelete); showNoTransaction(expectedModel); - assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); + CommandTestUtil.assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); + CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); - Index outOfBoundIndex = INDEX_SECOND_TRANSACTION; + Index outOfBoundIndex = TypicalIndexes.INDEX_SECOND_TRANSACTION; // ensures that outOfBoundIndex is still in bounds of transactions list - assertTrue(outOfBoundIndex.getZeroBased() < getTypicalUniCash().getTransactionList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < TypicalTransactions.getTypicalUniCash().getTransactionList().size()); DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, + CommandTestUtil.assertCommandFailure(deleteCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/unicash/logic/commands/EditPersonDescriptorTest.java similarity index 83% rename from src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java rename to src/test/java/unicash/logic/commands/EditPersonDescriptorTest.java index b93954b45b1..cdbf192d6ad 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/unicash/logic/commands/EditPersonDescriptorTest.java @@ -4,13 +4,13 @@ //import static org.junit.jupiter.api.Assertions.assertEquals; //import static org.junit.jupiter.api.Assertions.assertFalse; //import static org.junit.jupiter.api.Assertions.assertTrue; -//import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; -//import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -//import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +//import static commands.logic.unicash.CommandTestUtil.DESC_AMY; +//import static commands.logic.unicash.CommandTestUtil.DESC_BOB; +//import static commands.logic.unicash.CommandTestUtil.VALID_ADDRESS_BOB; +//import static commands.logic.unicash.CommandTestUtil.VALID_EMAIL_BOB; +//import static commands.logic.unicash.CommandTestUtil.VALID_NAME_BOB; +//import static commands.logic.unicash.CommandTestUtil.VALID_PHONE_BOB; +//import static commands.logic.unicash.CommandTestUtil.VALID_TAG_HUSBAND; // //import org.junit.jupiter.api.Test; // diff --git a/src/test/java/seedu/address/logic/commands/EditTransactionCommandTest.java b/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java similarity index 60% rename from src/test/java/seedu/address/logic/commands/EditTransactionCommandTest.java rename to src/test/java/unicash/logic/commands/EditTransactionCommandTest.java index bce3ea90e5e..4fdbf926033 100644 --- a/src/test/java/seedu/address/logic/commands/EditTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java @@ -1,55 +1,46 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.DESC_SHOPPING; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_DATETIME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showTransactionAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_TRANSACTION; -import static seedu.address.testutil.TypicalTransactions.getTypicalUniCash; +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; import org.junit.jupiter.api.Test; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.EditTransactionCommand.EditTransactionDescriptor; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UserPrefs; -import seedu.address.model.transaction.Transaction; -import seedu.address.testutil.EditTransactionDescriptorBuilder; -import seedu.address.testutil.TransactionBuilder; +import unicash.commons.core.index.Index; +import unicash.logic.UniCashMessages; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.UserPrefs; +import unicash.model.transaction.Transaction; +import unicash.testutil.EditTransactionDescriptorBuilder; +import unicash.testutil.TransactionBuilder; +import unicash.testutil.TypicalIndexes; +import unicash.testutil.TypicalTransactions; /** * Contains integration tests (interaction with the Model) and unit tests for EditTransactionCommand. */ public class EditTransactionCommandTest { - private final Model model = new ModelManager(getTypicalUniCash(), new UserPrefs()); + private final Model model = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { Transaction editedTransaction = new TransactionBuilder().build(); EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder( editedTransaction).build(); - EditTransactionCommand editTransactionCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, descriptor); + EditTransactionCommand editTransactionCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, descriptor); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - getTypicalUniCash(), new UserPrefs()); + TypicalTransactions.getTypicalUniCash(), new UserPrefs()); expectedModel.setTransaction(model.getFilteredTransactionList().get(0), editedTransaction); - assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test @@ -59,70 +50,70 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { TransactionBuilder transactionInList = new TransactionBuilder(lastTransaction); Transaction editedTransaction = transactionInList - .withName(VALID_TRANSACTION_NAME_NUS) - .withAmount(VALID_AMOUNT_NUS) - .withDateTime(VALID_DATETIME_NUS).build(); - - EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() - .withName(VALID_TRANSACTION_NAME_NUS) - .withAmount(VALID_AMOUNT_NUS) - .withDateTime(VALID_DATETIME_NUS).build(); + .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS) + .withAmount(CommandTestUtil.VALID_AMOUNT_NUS) + .withDateTime(CommandTestUtil.VALID_DATETIME_NUS).build(); + + EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() + .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS) + .withAmount(CommandTestUtil.VALID_AMOUNT_NUS) + .withDateTime(CommandTestUtil.VALID_DATETIME_NUS).build(); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(indexLastTransaction, descriptor); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - getTypicalUniCash(), new UserPrefs()); + TypicalTransactions.getTypicalUniCash(), new UserPrefs()); expectedModel.setTransaction(lastTransaction, editedTransaction); - assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test public void execute_noFieldSpecifiedUnfilteredList_success() { - EditTransactionCommand editTransactionCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, - new EditTransactionDescriptor()); - Transaction editedTransaction = model.getFilteredTransactionList().get(INDEX_FIRST_TRANSACTION.getZeroBased()); + EditTransactionCommand editTransactionCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, + new EditTransactionCommand.EditTransactionDescriptor()); + Transaction editedTransaction = model.getFilteredTransactionList().get(TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - getTypicalUniCash(), new UserPrefs()); + TypicalTransactions.getTypicalUniCash(), new UserPrefs()); - assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test public void execute_filteredList_success() { - showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); + CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); Transaction transactionInFilteredList = model.getFilteredTransactionList() - .get(INDEX_FIRST_TRANSACTION.getZeroBased()); + .get(TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); Transaction editedTransaction = new TransactionBuilder(transactionInFilteredList) - .withName(VALID_TRANSACTION_NAME_NUS).build(); - EditTransactionCommand editTransactionCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, - new EditTransactionDescriptorBuilder().withName(VALID_TRANSACTION_NAME_NUS).build()); + .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build(); + EditTransactionCommand editTransactionCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, + new EditTransactionDescriptorBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build()); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - getTypicalUniCash(), new UserPrefs()); + TypicalTransactions.getTypicalUniCash(), new UserPrefs()); expectedModel.setTransaction(model.getFilteredTransactionList().get(0), editedTransaction); - assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidTransactionIndexUnfilteredList_failure() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredTransactionList().size() + 1); - EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() - .withName(VALID_TRANSACTION_NAME_NUS).build(); + EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() + .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build(); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(outOfBoundIndex, descriptor); - assertCommandFailure(editTransactionCommand, model, + CommandTestUtil.assertCommandFailure(editTransactionCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } @@ -132,25 +123,25 @@ public void execute_invalidTransactionIndexUnfilteredList_failure() { */ @Test public void execute_invalidTransactionIndexFilteredList_failure() { - showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); - Index outOfBoundIndex = INDEX_SECOND_TRANSACTION; + CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); + Index outOfBoundIndex = TypicalIndexes.INDEX_SECOND_TRANSACTION; // ensures that outOfBoundIndex is still in bounds of address book list assertTrue(outOfBoundIndex.getZeroBased() < model.getUniCash().getTransactionList().size()); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(outOfBoundIndex, - new EditTransactionDescriptorBuilder().withName(VALID_TRANSACTION_NAME_NUS).build()); + new EditTransactionDescriptorBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build()); - assertCommandFailure(editTransactionCommand, model, + CommandTestUtil.assertCommandFailure(editTransactionCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } @Test public void equals() { - final EditTransactionCommand standardCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, DESC_NUS); + final EditTransactionCommand standardCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, CommandTestUtil.DESC_NUS); // same values -> returns true - EditTransactionDescriptor copyDescriptor = new EditTransactionDescriptor(DESC_NUS); - EditTransactionCommand commandWithSameValues = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, + EditTransactionCommand.EditTransactionDescriptor copyDescriptor = new EditTransactionCommand.EditTransactionDescriptor(CommandTestUtil.DESC_NUS); + EditTransactionCommand commandWithSameValues = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, copyDescriptor); assertEquals(standardCommand, commandWithSameValues); @@ -168,16 +159,16 @@ public void equals() { assertFalse(standardCommand.equals(copyDescriptor)); // different index -> returns false - assertNotEquals(standardCommand, new EditTransactionCommand(INDEX_SECOND_TRANSACTION, DESC_NUS)); + assertNotEquals(standardCommand, new EditTransactionCommand(TypicalIndexes.INDEX_SECOND_TRANSACTION, CommandTestUtil.DESC_NUS)); // different descriptor -> returns false - assertNotEquals(standardCommand, new EditTransactionCommand(INDEX_FIRST_TRANSACTION, DESC_SHOPPING)); + assertNotEquals(standardCommand, new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, CommandTestUtil.DESC_SHOPPING)); } @Test public void toStringMethod() { Index index = Index.fromOneBased(1); - EditTransactionDescriptor editTransactionDescriptor = new EditTransactionDescriptor(); + EditTransactionCommand.EditTransactionDescriptor editTransactionDescriptor = new EditTransactionCommand.EditTransactionDescriptor(); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(index, editTransactionDescriptor); String expected = EditTransactionCommand.class.getCanonicalName() + "{index=" + index + ", editTransactionDescriptor=" + editTransactionDescriptor + "}"; diff --git a/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java b/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java new file mode 100644 index 00000000000..0915eb5948e --- /dev/null +++ b/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java @@ -0,0 +1,24 @@ +package unicash.logic.commands; + +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; + +import org.junit.jupiter.api.Test; + +import unicash.model.Model; +import unicash.model.ModelManager; + +public class ExitCommandUniCashTest { + + private Model model = new ModelManager(); + private Model expectedModel = new ModelManager(); + + @Test + public void execute_exit_success() { + CommandResult expectedCommandResult = + new CommandResult(ExitCommandUniCash.MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); + + CommandTestUtil.assertCommandSuccess(new ExitCommandUniCash(), model, + expectedCommandResult, expectedModel); + } +} + diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/unicash/logic/commands/FindCommandTest.java similarity index 87% rename from src/test/java/seedu/address/logic/commands/FindCommandTest.java rename to src/test/java/unicash/logic/commands/FindCommandTest.java index 64f657b58bd..5bdcffc5627 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/unicash/logic/commands/FindCommandTest.java @@ -1,10 +1,10 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static seedu.address.logic.UniCashMessages.MESSAGE_TRANSACTIONS_LISTED_OVERVIEW; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static unicash.logic.UniCashMessages.MESSAGE_TRANSACTIONS_LISTED_OVERVIEW; +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; import java.util.Arrays; import java.util.Collections; @@ -12,11 +12,11 @@ import org.junit.jupiter.api.Test; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; -import seedu.address.model.transaction.TransactionNameContainsKeywordsPredicate; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.UniCash; +import unicash.model.UserPrefs; +import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. diff --git a/src/test/java/seedu/address/logic/commands/GetTotalExpenditureCommandTest.java b/src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java similarity index 85% rename from src/test/java/seedu/address/logic/commands/GetTotalExpenditureCommandTest.java rename to src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java index e7fcba507f2..5d1ffeb97c1 100644 --- a/src/test/java/seedu/address/logic/commands/GetTotalExpenditureCommandTest.java +++ b/src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java @@ -1,20 +1,22 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import seedu.address.commons.enums.TransactionType; -import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; -import seedu.address.model.category.Category; -import seedu.address.testutil.TransactionBuilder; +import unicash.commons.enums.TransactionType; +import unicash.logic.commands.exceptions.CommandException; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.UniCash; +import unicash.model.UserPrefs; +import unicash.model.category.Category; +import unicash.testutil.TransactionBuilder; +import unicash.testutil.Assert; public class GetTotalExpenditureCommandTest { @@ -23,19 +25,19 @@ public class GetTotalExpenditureCommandTest { @Test public void execute_nullModel_throwsNullPointerException() { var command = new GetTotalExpenditureCommand(10, null); - assertThrows(NullPointerException.class, () -> command.execute(null)); + Assert.assertThrows(NullPointerException.class, () -> command.execute(null)); } @Test public void execute_negativeMonth_throwsCommandException() { var command = new GetTotalExpenditureCommand(-12, null); - assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); + Assert.assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); } @Test public void execute_monthGreaterThan12_throwsCommandException() { var command = new GetTotalExpenditureCommand(13, null); - assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); + Assert.assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); } @Test @@ -65,7 +67,7 @@ public void execute_multipleMonthsOnly_filtersOnlySelectedMonths() throws Comman assertEquals(2, filteredResult.size()); for (var result : filteredResult) { assertEquals(TransactionType.EXPENSE, result.getType().type); - assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); + Assertions.assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); } } @@ -81,7 +83,7 @@ public void execute_multipleCategoriesOnly_filtersOnlySelectedCategory() throws assertEquals(2, filteredResult.size()); for (var result : filteredResult) { assertEquals(TransactionType.EXPENSE, result.getType().type); - assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); + Assertions.assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); } } @@ -97,8 +99,8 @@ public void execute_multipleMonthsAndCategories_filtersForSelectedMonthAndCatego assertEquals(1, filteredResult.size()); for (var result : filteredResult) { assertEquals(TransactionType.EXPENSE, result.getType().type); - assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); - assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); + Assertions.assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); + Assertions.assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); } } diff --git a/src/test/java/seedu/address/logic/commands/HelpCommandUniCashTest.java b/src/test/java/unicash/logic/commands/HelpCommandUniCashTest.java similarity index 62% rename from src/test/java/seedu/address/logic/commands/HelpCommandUniCashTest.java rename to src/test/java/unicash/logic/commands/HelpCommandUniCashTest.java index 5c6ede46ff6..802964858c3 100644 --- a/src/test/java/seedu/address/logic/commands/HelpCommandUniCashTest.java +++ b/src/test/java/unicash/logic/commands/HelpCommandUniCashTest.java @@ -1,12 +1,12 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.HelpCommandUniCash.SHOWING_HELP_MESSAGE; +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; +import static unicash.logic.commands.HelpCommandUniCash.SHOWING_HELP_MESSAGE; import org.junit.jupiter.api.Test; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; +import unicash.model.Model; +import unicash.model.ModelManager; public class HelpCommandUniCashTest { diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/unicash/logic/commands/ListCommandTest.java similarity index 59% rename from src/test/java/seedu/address/logic/commands/ListCommandTest.java rename to src/test/java/unicash/logic/commands/ListCommandTest.java index 841309d2208..59a5374a73e 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/unicash/logic/commands/ListCommandTest.java @@ -1,14 +1,14 @@ -package seedu.address.logic.commands; +package unicash.logic.commands; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; +import unicash.model.Model; +import unicash.model.ModelManager; +import unicash.model.UniCash; +import unicash.model.UserPrefs; /** * Contains integration tests (interaction with the Model) and unit tests for ListCommand. @@ -26,6 +26,6 @@ public void setUp() { @Test public void execute_listIsNotFiltered_showsSameList() { - assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); + CommandTestUtil.assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/parser/AddTransactionCommandParserTest.java b/src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java similarity index 63% rename from src/test/java/seedu/address/logic/parser/AddTransactionCommandParserTest.java rename to src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java index e10f57bb652..5aadf937351 100644 --- a/src/test/java/seedu/address/logic/parser/AddTransactionCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java @@ -1,46 +1,41 @@ -package seedu.address.logic.parser; - -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.AMOUNT_DESC_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.AMOUNT_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.CATEGORY_DESC_ENTERTAINMENT; -import static seedu.address.logic.commands.CommandTestUtil.CATEGORY_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_AMOUNT_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_CATEGORY_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATETIME_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_LOCATION_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_TRANSACTION_NAME_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_TYPE_DESC; -import static seedu.address.logic.commands.CommandTestUtil.LOCATION_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.LOCATION_DESC_ORCHARD; -import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; -import static seedu.address.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.TYPE_DESC_EXPENSE; -import static seedu.address.logic.commands.CommandTestUtil.TYPE_DESC_INCOME; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TYPE_EXPENSE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalTransactions.NUS; +package unicash.logic.parser; + +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.commands.CommandTestUtil.AMOUNT_DESC_INTERN; +import static unicash.logic.commands.CommandTestUtil.AMOUNT_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.CATEGORY_DESC_ENTERTAINMENT; +import static unicash.logic.commands.CommandTestUtil.CATEGORY_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.DATETIME_DESC_INTERN; +import static unicash.logic.commands.CommandTestUtil.DATETIME_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.INVALID_AMOUNT_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_CATEGORY_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_DATETIME_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_LOCATION_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_TRANSACTION_NAME_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_TYPE_DESC; +import static unicash.logic.commands.CommandTestUtil.LOCATION_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.LOCATION_DESC_ORCHARD; +import static unicash.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; +import static unicash.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_INTERN; +import static unicash.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.TYPE_DESC_EXPENSE; +import static unicash.logic.commands.CommandTestUtil.TYPE_DESC_INCOME; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_TYPE_EXPENSE; +import static unicash.logic.parser.CommandParserTestUtil.assertParseFailure; +import static unicash.logic.parser.CommandParserTestUtil.assertParseSuccess; +import static unicash.testutil.TypicalTransactions.NUS; import org.junit.jupiter.api.Test; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.AddTransactionCommand; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; -import seedu.address.testutil.TransactionBuilder; +import unicash.logic.UniCashMessages; +import unicash.logic.commands.AddTransactionCommand; +import unicash.model.transaction.*; +import unicash.model.transaction.Transaction; +import unicash.testutil.TransactionBuilder; +import unicash.model.transaction.Amount; +import unicash.model.transaction.Type; public class AddTransactionCommandParserTest { @@ -70,79 +65,79 @@ public void parse_repeatedValue_failure() { // multiple names assertParseFailure(parser, TRANSACTION_NAME_DESC_INTERN + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_NAME)); // multiple amount assertParseFailure(parser, AMOUNT_DESC_INTERN + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_AMOUNT)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_AMOUNT)); // multiple datetime assertParseFailure(parser, DATETIME_DESC_INTERN + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_DATETIME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_DATETIME)); // multiple type assertParseFailure(parser, TYPE_DESC_INCOME + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_TYPE)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_TYPE)); // multiple location assertParseFailure(parser, LOCATION_DESC_ORCHARD + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); // multiple category assertParseFailure(parser, CATEGORY_DESC_ENTERTAINMENT + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_CATEGORY)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_CATEGORY)); // invalid value followed by valid value // invalid name assertParseFailure(parser, INVALID_TRANSACTION_NAME_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_NAME)); // invalid amount assertParseFailure(parser, INVALID_AMOUNT_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_AMOUNT)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_AMOUNT)); // invalid datetime assertParseFailure(parser, INVALID_DATETIME_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_DATETIME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_DATETIME)); // invalid type assertParseFailure(parser, INVALID_TYPE_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_TYPE)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_TYPE)); // invalid category assertParseFailure(parser, INVALID_CATEGORY_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_CATEGORY)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_CATEGORY)); // invalid location assertParseFailure(parser, INVALID_LOCATION_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); // valid value followed by invalid value // invalid name assertParseFailure(parser, validExpectedTransactionString + INVALID_TRANSACTION_NAME_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_NAME)); // invalid amount assertParseFailure(parser, validExpectedTransactionString + INVALID_AMOUNT_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_AMOUNT)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_AMOUNT)); // invalid datetime assertParseFailure(parser, validExpectedTransactionString + INVALID_DATETIME_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_DATETIME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_DATETIME)); // invalid type assertParseFailure(parser, validExpectedTransactionString + INVALID_TYPE_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_TYPE)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_TYPE)); // invalid category assertParseFailure(parser, validExpectedTransactionString + INVALID_CATEGORY_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_CATEGORY)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_CATEGORY)); // invalid location assertParseFailure(parser, validExpectedTransactionString + INVALID_LOCATION_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); } @Test @@ -166,7 +161,7 @@ public void parse_compulsoryFieldMissing_failure() { public void parse_invalidValue_failure() { // invalid name assertParseFailure(parser, INVALID_TRANSACTION_NAME_DESC + AMOUNT_DESC_NUS + DATETIME_DESC_NUS - + TYPE_DESC_EXPENSE, seedu.address.model.transaction.Name.MESSAGE_CONSTRAINTS); + + TYPE_DESC_EXPENSE, Name.MESSAGE_CONSTRAINTS); // invalid amount assertParseFailure(parser, TRANSACTION_NAME_DESC_NUS + INVALID_AMOUNT_DESC diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/unicash/logic/parser/AddressBookParserTest.java similarity index 72% rename from src/test/java/seedu/address/logic/parser/AddressBookParserTest.java rename to src/test/java/unicash/logic/parser/AddressBookParserTest.java index 33e639ec51f..b7da9c860b1 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/unicash/logic/parser/AddressBookParserTest.java @@ -1,11 +1,10 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; +import static unicash.testutil.Assert.assertThrows; import java.util.Arrays; import java.util.List; @@ -13,21 +12,23 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.AddTransactionCommand; -import seedu.address.logic.commands.ClearTransactionsCommand; -import seedu.address.logic.commands.DeleteTransactionCommand; -import seedu.address.logic.commands.EditTransactionCommand; -import seedu.address.logic.commands.ExitCommandUniCash; -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.commands.GetTotalExpenditureCommand; -import seedu.address.logic.commands.HelpCommandUniCash; -import seedu.address.logic.commands.ListCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.TransactionNameContainsKeywordsPredicate; -import seedu.address.testutil.EditTransactionDescriptorBuilder; -import seedu.address.testutil.TransactionBuilder; -import seedu.address.testutil.TransactionUtil; +import unicash.logic.commands.AddTransactionCommand; +import unicash.logic.commands.ClearTransactionsCommand; +import unicash.logic.commands.DeleteTransactionCommand; +import unicash.logic.commands.EditTransactionCommand; +import unicash.logic.commands.ExitCommandUniCash; +import unicash.logic.commands.FindCommand; +import unicash.logic.commands.GetTotalExpenditureCommand; +import unicash.logic.commands.HelpCommandUniCash; +import unicash.logic.commands.ListCommand; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; +import unicash.testutil.EditTransactionDescriptorBuilder; +import unicash.testutil.TransactionBuilder; +import unicash.testutil.TransactionUtil; +import unicash.testutil.Assert; +import unicash.testutil.TypicalIndexes; public class AddressBookParserTest { @@ -71,8 +72,8 @@ public void parseCommand_deleteTransaction() throws Exception { DeleteTransactionCommand command = (DeleteTransactionCommand) parser.parseCommand( DeleteTransactionCommand.COMMAND_WORD + " " - + INDEX_FIRST_TRANSACTION.getOneBased()); - assertEquals(new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION), command); + + TypicalIndexes.INDEX_FIRST_TRANSACTION.getOneBased()); + assertEquals(new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION), command); } @Test @@ -87,10 +88,10 @@ public void parseCommand_editTransaction() throws Exception { Transaction transaction = new TransactionBuilder().build(); EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder(transaction) .build(); - String input = EditTransactionCommand.COMMAND_WORD + " " + INDEX_FIRST_TRANSACTION.getOneBased() + " "; + String input = EditTransactionCommand.COMMAND_WORD + " " + TypicalIndexes.INDEX_FIRST_TRANSACTION.getOneBased() + " "; input += TransactionUtil.getEditTransactionDescriptorDetails(descriptor); EditTransactionCommand command = (EditTransactionCommand) parser.parseCommand(input); - assertEquals(new EditTransactionCommand(INDEX_FIRST_TRANSACTION, descriptor), command); + assertEquals(new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, descriptor), command); } @Test @@ -124,11 +125,11 @@ public void parseCommand_exitUniCash() throws Exception { @Test public void parseCommand_unrecognisedInput_throwsParseException() { var message = String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommandUniCash.MESSAGE_USAGE); - assertThrows(ParseException.class, message, () -> parser.parseCommand("")); + Assert.assertThrows(ParseException.class, message, () -> parser.parseCommand("")); } @Test public void parseCommand_unknownCommand_throwsParseException() { - assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, () -> parser.parseCommand("unknownCommand")); + Assert.assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, () -> parser.parseCommand("unknownCommand")); } } diff --git a/src/test/java/seedu/address/logic/parser/ArgumentTokenizerTest.java b/src/test/java/unicash/logic/parser/ArgumentTokenizerTest.java similarity index 99% rename from src/test/java/seedu/address/logic/parser/ArgumentTokenizerTest.java rename to src/test/java/unicash/logic/parser/ArgumentTokenizerTest.java index c97308935f5..be77fcbe1da 100644 --- a/src/test/java/seedu/address/logic/parser/ArgumentTokenizerTest.java +++ b/src/test/java/unicash/logic/parser/ArgumentTokenizerTest.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/seedu/address/logic/parser/CommandParserTestUtil.java b/src/test/java/unicash/logic/parser/CommandParserTestUtil.java similarity index 79% rename from src/test/java/seedu/address/logic/parser/CommandParserTestUtil.java rename to src/test/java/unicash/logic/parser/CommandParserTestUtil.java index 8a917e51c15..b60047ef5ae 100644 --- a/src/test/java/seedu/address/logic/parser/CommandParserTestUtil.java +++ b/src/test/java/unicash/logic/parser/CommandParserTestUtil.java @@ -1,9 +1,10 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static org.junit.jupiter.api.Assertions.assertEquals; -import seedu.address.logic.commands.Command; -import seedu.address.logic.parser.exceptions.ParseException; +import org.junit.jupiter.api.Assertions; +import unicash.logic.commands.Command; +import unicash.logic.parser.exceptions.ParseException; /** * Contains helper methods for testing command parsers. @@ -15,7 +16,7 @@ public class CommandParserTestUtil { * equals to {@code expectedCommand}. */ public static void assertParseSuccess(Parser parser, String userInput, - Command expectedCommand) { + Command expectedCommand) { try { Command command = parser.parse(userInput); assertEquals(expectedCommand, command); @@ -33,7 +34,7 @@ public static void assertParseFailure(Parser parser, String u parser.parse(userInput); throw new AssertionError("The expected ParseException was not thrown."); } catch (ParseException | IllegalArgumentException e) { - assertEquals(expectedMessage, e.getMessage()); + Assertions.assertEquals(expectedMessage, e.getMessage()); } } } diff --git a/src/test/java/seedu/address/logic/parser/DeleteTransactionCommandParserTest.java b/src/test/java/unicash/logic/parser/DeleteTransactionCommandParserTest.java similarity index 83% rename from src/test/java/seedu/address/logic/parser/DeleteTransactionCommandParserTest.java rename to src/test/java/unicash/logic/parser/DeleteTransactionCommandParserTest.java index 0eb384b07e3..b3362d3364f 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteTransactionCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/DeleteTransactionCommandParserTest.java @@ -1,13 +1,13 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.DeleteTransactionCommand; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.commons.core.index.Index; +import unicash.logic.commands.DeleteTransactionCommand; +import unicash.logic.parser.exceptions.ParseException; public class DeleteTransactionCommandParserTest { diff --git a/src/test/java/seedu/address/logic/parser/EditTransactionCommandParserTest.java b/src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java similarity index 70% rename from src/test/java/seedu/address/logic/parser/EditTransactionCommandParserTest.java rename to src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java index 8c88d83751b..8cf2a02900b 100644 --- a/src/test/java/seedu/address/logic/parser/EditTransactionCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java @@ -1,60 +1,55 @@ -package seedu.address.logic.parser; - -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.AMOUNT_DESC_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.AMOUNT_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.CATEGORY_DESC_ENTERTAINMENT; -import static seedu.address.logic.commands.CommandTestUtil.CATEGORY_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_AMOUNT_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_CATEGORY_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATETIME_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_LOCATION_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_TRANSACTION_NAME_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_TYPE_DESC; -import static seedu.address.logic.commands.CommandTestUtil.LOCATION_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.LOCATION_DESC_ORCHARD; -import static seedu.address.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_NUS; -import static seedu.address.logic.commands.CommandTestUtil.TYPE_DESC_EXPENSE; -import static seedu.address.logic.commands.CommandTestUtil.TYPE_DESC_INCOME; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_CATEGORY_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_DATETIME_INTERN; -import static seedu.address.logic.commands.CommandTestUtil.VALID_DATETIME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_LOCATION_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TYPE_INCOME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_AMOUNT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TYPE; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_TRANSACTION; -import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_TRANSACTION; +package unicash.logic.parser; + +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.commands.CommandTestUtil.AMOUNT_DESC_INTERN; +import static unicash.logic.commands.CommandTestUtil.AMOUNT_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.CATEGORY_DESC_ENTERTAINMENT; +import static unicash.logic.commands.CommandTestUtil.CATEGORY_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.DATETIME_DESC_INTERN; +import static unicash.logic.commands.CommandTestUtil.DATETIME_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.INVALID_AMOUNT_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_CATEGORY_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_DATETIME_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_LOCATION_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_TRANSACTION_NAME_DESC; +import static unicash.logic.commands.CommandTestUtil.INVALID_TYPE_DESC; +import static unicash.logic.commands.CommandTestUtil.LOCATION_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.LOCATION_DESC_ORCHARD; +import static unicash.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.TYPE_DESC_EXPENSE; +import static unicash.logic.commands.CommandTestUtil.TYPE_DESC_INCOME; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_CATEGORY_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_DATETIME_INTERN; +import static unicash.logic.commands.CommandTestUtil.VALID_DATETIME_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_LOCATION_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_TYPE_INCOME; +import static unicash.logic.parser.CommandParserTestUtil.assertParseFailure; +import static unicash.logic.parser.CommandParserTestUtil.assertParseSuccess; +import static unicash.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; +import static unicash.testutil.TypicalIndexes.INDEX_SECOND_TRANSACTION; +import static unicash.testutil.TypicalIndexes.INDEX_THIRD_TRANSACTION; import org.junit.jupiter.api.Test; -import seedu.address.commons.core.index.Index; -import seedu.address.logic.UniCashMessages; -import seedu.address.logic.commands.EditTransactionCommand; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Type; -import seedu.address.testutil.EditTransactionDescriptorBuilder; +import unicash.commons.core.index.Index; +import unicash.logic.UniCashMessages; +import unicash.logic.commands.EditTransactionCommand; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Type; +import unicash.testutil.EditTransactionDescriptorBuilder; public class EditTransactionCommandParserTest { private static final String MESSAGE_INVALID_FORMAT = String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditTransactionCommand.MESSAGE_USAGE); - private static final String CATEGORY_EMPTY = " " + PREFIX_CATEGORY; + private static final String CATEGORY_EMPTY = " " + CliSyntax.PREFIX_CATEGORY; private final EditTransactionCommandParser parser = new EditTransactionCommandParser(); @@ -232,12 +227,12 @@ public void parse_multipleRepeatedFields_failure() { Index targetIndex = INDEX_FIRST_TRANSACTION; String userInput = targetIndex.getOneBased() + LOCATION_DESC_NUS + INVALID_LOCATION_DESC; - assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); + assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); // invalid followed by valid userInput = targetIndex.getOneBased() + INVALID_LOCATION_DESC + LOCATION_DESC_NUS; - assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); + assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); // multiple valid fields repeated userInput = targetIndex.getOneBased() @@ -261,11 +256,11 @@ public void parse_multipleRepeatedFields_failure() { parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes( - PREFIX_LOCATION, - PREFIX_TYPE, - PREFIX_AMOUNT, - PREFIX_DATETIME, - PREFIX_CATEGORY + CliSyntax.PREFIX_LOCATION, + CliSyntax.PREFIX_TYPE, + CliSyntax.PREFIX_AMOUNT, + CliSyntax.PREFIX_DATETIME, + CliSyntax.PREFIX_CATEGORY ) ); @@ -282,9 +277,9 @@ public void parse_multipleRepeatedFields_failure() { parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes( - PREFIX_LOCATION, - PREFIX_CATEGORY, - PREFIX_DATETIME + CliSyntax.PREFIX_LOCATION, + CliSyntax.PREFIX_CATEGORY, + CliSyntax.PREFIX_DATETIME ) ); } diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/unicash/logic/parser/FindCommandParserTest.java similarity index 53% rename from src/test/java/seedu/address/logic/parser/FindCommandParserTest.java rename to src/test/java/unicash/logic/parser/FindCommandParserTest.java index 70d85f965a5..fe2acecffc6 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/FindCommandParserTest.java @@ -1,15 +1,13 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; import java.util.Arrays; import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.FindCommand; -import seedu.address.model.transaction.TransactionNameContainsKeywordsPredicate; +import unicash.logic.commands.FindCommand; +import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; /** * A class to test the FindCommandParser. @@ -20,7 +18,7 @@ public class FindCommandParserTest { @Test public void parse_emptyArg_throwsParseException() { - assertParseFailure(parser, " ", + CommandParserTestUtil.assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); } @@ -29,10 +27,10 @@ public void parse_validArgs_returnsFindCommand() { // no leading and trailing whitespaces FindCommand expectedFindCommand = new FindCommand(new TransactionNameContainsKeywordsPredicate(Arrays.asList("Shopping", "Work"))); - assertParseSuccess(parser, "Shopping Work", expectedFindCommand); + CommandParserTestUtil.assertParseSuccess(parser, "Shopping Work", expectedFindCommand); // multiple whitespaces between keywords - assertParseSuccess(parser, " \n Shopping \n \t Work \t", expectedFindCommand); + CommandParserTestUtil.assertParseSuccess(parser, " \n Shopping \n \t Work \t", expectedFindCommand); } } diff --git a/src/test/java/seedu/address/logic/parser/GetTotalExpenditureCommandParserTest.java b/src/test/java/unicash/logic/parser/GetTotalExpenditureCommandParserTest.java similarity index 76% rename from src/test/java/seedu/address/logic/parser/GetTotalExpenditureCommandParserTest.java rename to src/test/java/unicash/logic/parser/GetTotalExpenditureCommandParserTest.java index df277fd31f9..c99a2045ae2 100644 --- a/src/test/java/seedu/address/logic/parser/GetTotalExpenditureCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/GetTotalExpenditureCommandParserTest.java @@ -1,13 +1,13 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static seedu.address.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.GetTotalExpenditureCommand; -import seedu.address.logic.parser.exceptions.ParseException; +import unicash.logic.commands.GetTotalExpenditureCommand; +import unicash.logic.parser.exceptions.ParseException; public class GetTotalExpenditureCommandParserTest { private final GetTotalExpenditureCommandParser parser = new GetTotalExpenditureCommandParser(); diff --git a/src/test/java/seedu/address/logic/parser/ListCommandParserTest.java b/src/test/java/unicash/logic/parser/ListCommandParserTest.java similarity index 71% rename from src/test/java/seedu/address/logic/parser/ListCommandParserTest.java rename to src/test/java/unicash/logic/parser/ListCommandParserTest.java index c8eacf373d2..6dcab920dfb 100644 --- a/src/test/java/seedu/address/logic/parser/ListCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/ListCommandParserTest.java @@ -1,10 +1,10 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; +import static unicash.logic.parser.CommandParserTestUtil.assertParseFailure; import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.ListCommand; +import unicash.logic.commands.ListCommand; public class ListCommandParserTest { private final ListCommandParser parser = new ListCommandParser(); diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/unicash/logic/parser/ParserUtilTest.java similarity index 65% rename from src/test/java/seedu/address/logic/parser/ParserUtilTest.java rename to src/test/java/unicash/logic/parser/ParserUtilTest.java index 2a3771913c8..74f513eef8f 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/unicash/logic/parser/ParserUtilTest.java @@ -1,25 +1,26 @@ -package seedu.address.logic.parser; +package unicash.logic.parser; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.parser.ParserUtil.MESSAGE_INVALID_INDEX; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static unicash.testutil.Assert.assertThrows; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; +import unicash.logic.parser.exceptions.ParseException; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.testutil.Assert; +import unicash.testutil.TypicalIndexes; // TODO: Need more testing here public class ParserUtilTest { @@ -39,91 +40,91 @@ public class ParserUtilTest { @Test public void parseIndex_invalidInput_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseIndex("10 a")); + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseIndex("10 a")); } @Test public void parseIndex_outOfRangeInput_throwsParseException() { - assertThrows(ParseException.class, MESSAGE_INVALID_INDEX, () + Assert.assertThrows(ParseException.class, ParserUtil.MESSAGE_INVALID_INDEX, () -> ParserUtil.parseIndex(Long.toString(Integer.MAX_VALUE + 1))); } @Test public void parseIndex_validInput_success() throws Exception { // No whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); + Assertions.assertEquals(TypicalIndexes.INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); // Leading and trailing whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); + Assertions.assertEquals(TypicalIndexes.INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); } @Test public void parseTransactionName_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseTransactionName(null)); + Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseTransactionName(null)); } @Test public void parseTransactionName_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseTransactionName(INVALID_NAME)); + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseTransactionName(INVALID_NAME)); } @Test public void parseTransactionName_validValueWithoutWhitespace_returnsTransactionName() throws Exception { Name expectedTransactionName = new Name(VALID_NAME); - assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(VALID_NAME)); + Assertions.assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(VALID_NAME)); } @Test public void parseTransactionName_validValueWithWhitespace_returnsTrimmedTransactionName() throws Exception { String nameWithWhitespace = WHITESPACE + VALID_NAME + WHITESPACE; Name expectedTransactionName = new Name(VALID_NAME); - assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(nameWithWhitespace)); + Assertions.assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(nameWithWhitespace)); } @Test public void parseAmount_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseAmount(null)); + Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseAmount(null)); } @Test public void parseAmount_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseAmount(INVALID_AMOUNT)); + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseAmount(INVALID_AMOUNT)); } @Test public void parseAmount_validValueWithoutWhitespace_returnsTransactionName() throws Exception { Amount expectedAmount = new Amount(3.0); - assertEquals(expectedAmount, ParserUtil.parseAmount(VALID_AMOUNT)); + Assertions.assertEquals(expectedAmount, ParserUtil.parseAmount(VALID_AMOUNT)); } @Test public void parseAmount_validValueWithWhitespace_returnsTrimmedTransactionName() throws Exception { String amountWithWhitespace = WHITESPACE + VALID_AMOUNT + WHITESPACE; Amount expectedAmount = new Amount(3.0); - assertEquals(expectedAmount, ParserUtil.parseAmount(amountWithWhitespace)); + Assertions.assertEquals(expectedAmount, ParserUtil.parseAmount(amountWithWhitespace)); } @Test public void parseDateTime_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseDateTime(null)); + Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseDateTime(null)); } @Test public void parseDateTime_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseDateTime(INVALID_DATETIME)); + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseDateTime(INVALID_DATETIME)); } @Test public void parseDateTime_validValueWithoutWhitespace_returnsTransactionName() throws Exception { DateTime expectedDateTime = new DateTime(VALID_DATETIME); - assertEquals(expectedDateTime, ParserUtil.parseDateTime(VALID_DATETIME)); + Assertions.assertEquals(expectedDateTime, ParserUtil.parseDateTime(VALID_DATETIME)); } @Test public void parseDateTime_validValueWithWhitespace_returnsTrimmedTransactionName() throws Exception { String dateTimeWithWhiteSpace = WHITESPACE + VALID_DATETIME + WHITESPACE; DateTime expectedDateTime = new DateTime(VALID_DATETIME); - assertEquals(expectedDateTime, ParserUtil.parseDateTime(dateTimeWithWhiteSpace)); + Assertions.assertEquals(expectedDateTime, ParserUtil.parseDateTime(dateTimeWithWhiteSpace)); } @Test @@ -134,64 +135,64 @@ public void parseCategory_empty_doesNotThrow() throws Exception { @Test public void parseLocation_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseLocation(null)); + Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseLocation(null)); } @Test public void parseLocation_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseLocation(INVALID_LOCATION)); + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseLocation(INVALID_LOCATION)); } @Test public void parseLocation_validValueWithoutWhitespace_returnsTransactionName() throws Exception { Location expectedLocation = new Location(VALID_LOCATION); - assertEquals(expectedLocation, ParserUtil.parseLocation(VALID_LOCATION)); + Assertions.assertEquals(expectedLocation, ParserUtil.parseLocation(VALID_LOCATION)); } @Test public void parseLocation_validValueWithWhitespace_returnsTrimmedLocation() throws Exception { String locationWithWhiteSpace = WHITESPACE + VALID_LOCATION + WHITESPACE; Location expectedLocation = new Location(VALID_LOCATION); - assertEquals(expectedLocation, ParserUtil.parseLocation(locationWithWhiteSpace)); + Assertions.assertEquals(expectedLocation, ParserUtil.parseLocation(locationWithWhiteSpace)); } @Test public void parseLocation_empty_returnsDefaultLocation() throws Exception { Location expectedLocation = new Location(WHITESPACE); - assertEquals(expectedLocation, ParserUtil.parseLocation(WHITESPACE)); + Assertions.assertEquals(expectedLocation, ParserUtil.parseLocation(WHITESPACE)); } @Test public void parseCategory_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseCategory(null)); + Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseCategory(null)); } @Test public void parseCategory_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseCategory(INVALID_CATEGORY)); + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseCategory(INVALID_CATEGORY)); } @Test public void parseCategory_validValueWithoutWhitespace_returnsCategory() throws Exception { Category expectedCategory = new Category(VALID_CATEGORY); - assertEquals(expectedCategory, ParserUtil.parseCategory(VALID_CATEGORY)); + Assertions.assertEquals(expectedCategory, ParserUtil.parseCategory(VALID_CATEGORY)); } @Test public void parseCategory_validValueWithWhitespace_returnsTrimmedCategory() throws Exception { String categoryWithWhitespace = WHITESPACE + VALID_CATEGORY + WHITESPACE; Category expectedCategory = new Category(VALID_CATEGORY); - assertEquals(expectedCategory, ParserUtil.parseCategory(categoryWithWhitespace)); + Assertions.assertEquals(expectedCategory, ParserUtil.parseCategory(categoryWithWhitespace)); } @Test public void parseCategories_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseCategories(null)); + Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseCategories(null)); } @Test public void parseCategories_collectionWithInvalidCategories_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseCategories( + Assert.assertThrows(ParseException.class, () -> ParserUtil.parseCategories( Arrays.asList(VALID_CATEGORY, INVALID_CATEGORY))); } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/unicash/model/ModelManagerTest.java similarity index 75% rename from src/test/java/seedu/address/model/ModelManagerTest.java rename to src/test/java/unicash/model/ModelManagerTest.java index 6b6297496b2..c0a5c39ab67 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/unicash/model/ModelManagerTest.java @@ -1,26 +1,27 @@ -package seedu.address.model; +package unicash.model; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TRANSACTIONS; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.BUYING_GROCERIES; -import static seedu.address.testutil.TypicalTransactions.INTERN; -import static seedu.address.testutil.TypicalTransactions.NUS; +import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.BUYING_GROCERIES; +import static unicash.testutil.TypicalTransactions.INTERN; +import static unicash.testutil.TypicalTransactions.NUS; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import seedu.address.commons.core.GuiSettings; -import seedu.address.model.transaction.TransactionNameContainsKeywordsPredicate; -import seedu.address.model.transaction.exceptions.TransactionNotFoundException; -import seedu.address.testutil.UniCashBuilder; +import unicash.commons.core.GuiSettings; +import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; +import unicash.model.transaction.exceptions.TransactionNotFoundException; +import unicash.testutil.UniCashBuilder; +import unicash.testutil.Assert; public class ModelManagerTest { @@ -29,13 +30,13 @@ public class ModelManagerTest { @Test public void constructor() { assertEquals(new UserPrefs(), modelManager.getUserPrefs()); - assertEquals(new GuiSettings(), modelManager.getGuiSettings()); + Assertions.assertEquals(new GuiSettings(), modelManager.getGuiSettings()); assertEquals(new UniCash(), new UniCash(modelManager.getUniCash())); } @Test public void setUserPrefs_nullUserPrefs_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.setUserPrefs(null)); + Assert.assertThrows(NullPointerException.class, () -> modelManager.setUserPrefs(null)); } @Test @@ -54,19 +55,19 @@ public void setUserPrefs_validUserPrefs_copiesUserPrefs() { @Test public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.setGuiSettings(null)); + Assert.assertThrows(NullPointerException.class, () -> modelManager.setGuiSettings(null)); } @Test public void setGuiSettings_validGuiSettings_setsGuiSettings() { GuiSettings guiSettings = new GuiSettings(1, 2, 3, 4); modelManager.setGuiSettings(guiSettings); - assertEquals(guiSettings, modelManager.getGuiSettings()); + Assertions.assertEquals(guiSettings, modelManager.getGuiSettings()); } @Test public void setUniCashFilePath_nullPath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.setUniCashFilePath(null)); + Assert.assertThrows(NullPointerException.class, () -> modelManager.setUniCashFilePath(null)); } @Test @@ -78,12 +79,12 @@ public void setUniCashFilePath_validPath_setsUniCashFilePath() { @Test public void setUniCash_nullTransaction_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.setUniCash(null)); + Assert.assertThrows(NullPointerException.class, () -> modelManager.setUniCash(null)); } @Test public void hasTransaction_nullTransaction_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.hasTransaction(null)); + Assert.assertThrows(NullPointerException.class, () -> modelManager.hasTransaction(null)); } @Test @@ -100,7 +101,7 @@ public void hasTransaction_transactionInUniCash_returnsTrue() { @Test public void deleteTransaction_transactionNotInUniCash_throws() { modelManager.addTransaction(NUS); - assertThrows(TransactionNotFoundException.class, () -> modelManager.deleteTransaction(BUYING_GROCERIES)); + Assert.assertThrows(TransactionNotFoundException.class, () -> modelManager.deleteTransaction(BUYING_GROCERIES)); } @Test @@ -111,7 +112,7 @@ public void deleteTransaction_transactionInUniCash_throws() { @Test public void getFilteredUniCash_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredTransactionList().remove(0)); + Assert.assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredTransactionList().remove(0)); } @Test @@ -145,7 +146,7 @@ public void equals() { assertFalse(modelManager.equals(new ModelManager(uniCash, userPrefs))); // resets modelManager to initial state for upcoming tests - modelManager.updateFilteredTransactionList(PREDICATE_SHOW_ALL_TRANSACTIONS); + modelManager.updateFilteredTransactionList(Model.PREDICATE_SHOW_ALL_TRANSACTIONS); // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); diff --git a/src/test/java/seedu/address/model/UniCashTest.java b/src/test/java/unicash/model/UniCashTest.java similarity index 87% rename from src/test/java/seedu/address/model/UniCashTest.java rename to src/test/java/unicash/model/UniCashTest.java index fea7d7cecc9..53854173b9d 100644 --- a/src/test/java/seedu/address/model/UniCashTest.java +++ b/src/test/java/unicash/model/UniCashTest.java @@ -1,16 +1,16 @@ -package seedu.address.model; +package unicash.model; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.BUYING_GROCERIES; -import static seedu.address.testutil.TypicalTransactions.INTERN; -import static seedu.address.testutil.TypicalTransactions.NUS; -import static seedu.address.testutil.TypicalTransactions.getTypicalUniCash; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; +import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.BUYING_GROCERIES; +import static unicash.testutil.TypicalTransactions.INTERN; +import static unicash.testutil.TypicalTransactions.NUS; +import static unicash.testutil.TypicalTransactions.getTypicalUniCash; import java.util.Arrays; import java.util.Collection; @@ -21,10 +21,10 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.exceptions.TransactionNotFoundException; -import seedu.address.testutil.TransactionBuilder; -import seedu.address.testutil.UniCashBuilder; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.exceptions.TransactionNotFoundException; +import unicash.testutil.TransactionBuilder; +import unicash.testutil.UniCashBuilder; public class UniCashTest { diff --git a/src/test/java/seedu/address/model/UserPrefsTest.java b/src/test/java/unicash/model/UserPrefsTest.java similarity index 76% rename from src/test/java/seedu/address/model/UserPrefsTest.java rename to src/test/java/unicash/model/UserPrefsTest.java index 12c4c981579..52165a2ef69 100644 --- a/src/test/java/seedu/address/model/UserPrefsTest.java +++ b/src/test/java/unicash/model/UserPrefsTest.java @@ -1,28 +1,29 @@ -package seedu.address.model; +package unicash.model; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.nio.file.Path; import org.junit.jupiter.api.Test; -import seedu.address.commons.core.GuiSettings; +import unicash.commons.core.GuiSettings; +import unicash.testutil.Assert; public class UserPrefsTest { @Test public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { UserPrefs userPref = new UserPrefs(); - assertThrows(NullPointerException.class, () -> userPref.setGuiSettings(null)); + Assert.assertThrows(NullPointerException.class, () -> userPref.setGuiSettings(null)); } @Test public void setUniCashFilePath_nullPath_throwsNullPointerException() { UserPrefs userPrefs = new UserPrefs(); - assertThrows(NullPointerException.class, () -> userPrefs.setUniCashFilePath(null)); + Assert.assertThrows(NullPointerException.class, () -> userPrefs.setUniCashFilePath(null)); } @Test diff --git a/src/test/java/seedu/address/model/category/CategoryTest.java b/src/test/java/unicash/model/category/CategoryTest.java similarity index 93% rename from src/test/java/seedu/address/model/category/CategoryTest.java rename to src/test/java/unicash/model/category/CategoryTest.java index 61b568567d0..3edfc84c405 100644 --- a/src/test/java/seedu/address/model/category/CategoryTest.java +++ b/src/test/java/unicash/model/category/CategoryTest.java @@ -1,8 +1,8 @@ -package seedu.address.model.category; +package unicash.model.category; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; diff --git a/src/test/java/seedu/address/model/transaction/AmountTest.java b/src/test/java/unicash/model/transaction/AmountTest.java similarity index 83% rename from src/test/java/seedu/address/model/transaction/AmountTest.java rename to src/test/java/unicash/model/transaction/AmountTest.java index 08d62095b79..67e9f9d5e0c 100644 --- a/src/test/java/seedu/address/model/transaction/AmountTest.java +++ b/src/test/java/unicash/model/transaction/AmountTest.java @@ -1,17 +1,18 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class AmountTest { @Test public void constructor_negativeAmount_throwsIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> new Amount(-10)); + Assert.assertThrows(IllegalArgumentException.class, () -> new Amount(-10)); } @Test diff --git a/src/test/java/seedu/address/model/transaction/DateTimeTest.java b/src/test/java/unicash/model/transaction/DateTimeTest.java similarity index 88% rename from src/test/java/seedu/address/model/transaction/DateTimeTest.java rename to src/test/java/unicash/model/transaction/DateTimeTest.java index 7870677a0a5..5ffadad35cd 100644 --- a/src/test/java/seedu/address/model/transaction/DateTimeTest.java +++ b/src/test/java/unicash/model/transaction/DateTimeTest.java @@ -1,23 +1,24 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.time.Clock; import java.time.Instant; import java.time.ZoneId; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class DateTimeTest { @Test public void constructor_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new DateTime(null)); - assertThrows(NullPointerException.class, () -> new DateTime("18-08-2001 18:18", null)); - assertThrows(NullPointerException.class, () -> new DateTime(null, null)); + Assert.assertThrows(NullPointerException.class, () -> new DateTime(null)); + Assert.assertThrows(NullPointerException.class, () -> new DateTime("18-08-2001 18:18", null)); + Assert.assertThrows(NullPointerException.class, () -> new DateTime(null, null)); } @Test diff --git a/src/test/java/seedu/address/model/transaction/LocationTest.java b/src/test/java/unicash/model/transaction/LocationTest.java similarity index 89% rename from src/test/java/seedu/address/model/transaction/LocationTest.java rename to src/test/java/unicash/model/transaction/LocationTest.java index 53aba4d2e1b..922f99dc3a3 100644 --- a/src/test/java/seedu/address/model/transaction/LocationTest.java +++ b/src/test/java/unicash/model/transaction/LocationTest.java @@ -1,18 +1,19 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class LocationTest { @Test public void constructor_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new Location(null)); + Assert.assertThrows(NullPointerException.class, () -> new Location(null)); } @Test @@ -24,7 +25,7 @@ public void constructor_noLocation_setDefault() { @Test public void isValidLocation() { // null name - assertThrows(NullPointerException.class, () -> Location.isValidLocation(null)); + Assert.assertThrows(NullPointerException.class, () -> Location.isValidLocation(null)); // invalid name assertFalse(Location.isValidLocation("")); // empty string diff --git a/src/test/java/seedu/address/model/transaction/NameTest.java b/src/test/java/unicash/model/transaction/NameTest.java similarity index 83% rename from src/test/java/seedu/address/model/transaction/NameTest.java rename to src/test/java/unicash/model/transaction/NameTest.java index 4f6874bb260..2a4eee93603 100644 --- a/src/test/java/seedu/address/model/transaction/NameTest.java +++ b/src/test/java/unicash/model/transaction/NameTest.java @@ -1,30 +1,31 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class NameTest { @Test public void constructor_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new Name(null)); + Assert.assertThrows(NullPointerException.class, () -> new Name(null)); } @Test public void constructor_invalidName_throwsIllegalArgumentException() { String invalidName = ""; - assertThrows(IllegalArgumentException.class, () -> new Name(invalidName)); + Assert.assertThrows(IllegalArgumentException.class, () -> new Name(invalidName)); } @Test public void isValidName() { // null name - assertThrows(NullPointerException.class, () -> Name.isValidName(null)); + Assert.assertThrows(NullPointerException.class, () -> Name.isValidName(null)); // invalid name assertFalse(Name.isValidName("")); // empty string diff --git a/src/test/java/seedu/address/model/transaction/TransactionListTest.java b/src/test/java/unicash/model/transaction/TransactionListTest.java similarity index 93% rename from src/test/java/seedu/address/model/transaction/TransactionListTest.java rename to src/test/java/unicash/model/transaction/TransactionListTest.java index 159abe39bba..0f8e677c3ce 100644 --- a/src/test/java/seedu/address/model/transaction/TransactionListTest.java +++ b/src/test/java/unicash/model/transaction/TransactionListTest.java @@ -1,22 +1,22 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.BUYING_GROCERIES; -import static seedu.address.testutil.TypicalTransactions.NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; +import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.BUYING_GROCERIES; +import static unicash.testutil.TypicalTransactions.NUS; import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -import seedu.address.model.transaction.exceptions.TransactionNotFoundException; -import seedu.address.testutil.TransactionBuilder; +import unicash.model.transaction.exceptions.TransactionNotFoundException; +import unicash.testutil.TransactionBuilder; public class TransactionListTest { diff --git a/src/test/java/seedu/address/model/transaction/TransactionNameContainsKeywordsPredicateTest.java b/src/test/java/unicash/model/transaction/TransactionNameContainsKeywordsPredicateTest.java similarity index 97% rename from src/test/java/seedu/address/model/transaction/TransactionNameContainsKeywordsPredicateTest.java rename to src/test/java/unicash/model/transaction/TransactionNameContainsKeywordsPredicateTest.java index f519d17118b..494a63d813f 100644 --- a/src/test/java/seedu/address/model/transaction/TransactionNameContainsKeywordsPredicateTest.java +++ b/src/test/java/unicash/model/transaction/TransactionNameContainsKeywordsPredicateTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; -import seedu.address.testutil.TransactionBuilder; +import unicash.testutil.TransactionBuilder; public class TransactionNameContainsKeywordsPredicateTest { diff --git a/src/test/java/unicash/model/transaction/TransactionTest.java b/src/test/java/unicash/model/transaction/TransactionTest.java new file mode 100644 index 00000000000..fc25b712cfc --- /dev/null +++ b/src/test/java/unicash/model/transaction/TransactionTest.java @@ -0,0 +1,84 @@ +package unicash.model.transaction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import unicash.testutil.TransactionBuilder; +import unicash.testutil.TypicalTransactions; + +public class TransactionTest { + + @Test + public void equals() { + // same values -> returns true + Transaction groceriesCopy = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).build(); + Assertions.assertEquals(TypicalTransactions.BUYING_GROCERIES, groceriesCopy); + + // same object -> returns true + Assertions.assertEquals(TypicalTransactions.BUYING_GROCERIES, TypicalTransactions.BUYING_GROCERIES); + + // null -> returns false + assertNotEquals(null, groceriesCopy); + + // null -> returns false + Assertions.assertNotEquals(null, TypicalTransactions.BUYING_GROCERIES); + + // different type -> returns false + Assertions.assertNotEquals(5, TypicalTransactions.BUYING_GROCERIES); + + Assertions.assertFalse(TypicalTransactions.BUYING_GROCERIES.equals(5)); + + // different person -> returns false + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, TypicalTransactions.DINING_WITH_FRIENDS); + + // different name -> returns false + Transaction editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withName("Another thing").build(); + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + + // different amount -> returns false + editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withAmount(10.15).build(); + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + + // different date -> returns false + editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES) + .withDateTime("01-01-1999 18:18") + .build(); + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + + // different location -> returns false + editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withLocation("UTown").build(); + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + + // different transaction type -> return false + editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withType("expense").build(); + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + + // different categories -> returns false + editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withCategories("TEST").build(); + Assertions.assertFalse(TypicalTransactions.BUYING_GROCERIES.equals(editedGroceries)); + } + + @Test + public void toStringMethod() { + String expected = + Transaction.class.getCanonicalName() + + "{name=" + TypicalTransactions.BUYING_GROCERIES.getName() + + ", type=" + TypicalTransactions.BUYING_GROCERIES.getType() + + ", amount=" + TypicalTransactions.BUYING_GROCERIES.getAmount() + + ", dateTime=" + TypicalTransactions.BUYING_GROCERIES.getDateTime() + + ", location=" + TypicalTransactions.BUYING_GROCERIES.getLocation() + + ", categories=" + TypicalTransactions.BUYING_GROCERIES.getCategories() + + "}"; + Assertions.assertEquals(expected, TypicalTransactions.BUYING_GROCERIES.toString()); + } + + @Test + public void hashCode_test() { + Assertions.assertEquals(TypicalTransactions.BUYING_GROCERIES.hashCode(), TypicalTransactions.BUYING_GROCERIES.hashCode()); + Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES.hashCode(), TypicalTransactions.WORK_AT_LIHO.hashCode()); + } +} diff --git a/src/test/java/seedu/address/model/transaction/TypeTest.java b/src/test/java/unicash/model/transaction/TypeTest.java similarity index 87% rename from src/test/java/seedu/address/model/transaction/TypeTest.java rename to src/test/java/unicash/model/transaction/TypeTest.java index 0ae76e4b867..9fd3d3f1680 100644 --- a/src/test/java/seedu/address/model/transaction/TypeTest.java +++ b/src/test/java/unicash/model/transaction/TypeTest.java @@ -1,25 +1,26 @@ -package seedu.address.model.transaction; +package unicash.model.transaction; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; +import unicash.testutil.Assert; public class TypeTest { @Test public void constructor_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new Type(null)); + Assert.assertThrows(NullPointerException.class, () -> new Type(null)); } @Test public void constructor_invalidType_throwsIllegalArgumentException() { String[] invalidTypes = new String[] {"", "1", "Wrong"}; for (String invalidType: invalidTypes) { - assertThrows(IllegalArgumentException.class, () -> new Type(invalidType)); + Assert.assertThrows(IllegalArgumentException.class, () -> new Type(invalidType)); } } diff --git a/src/test/java/seedu/address/storage/JsonAdaptedTransactionTest.java b/src/test/java/unicash/storage/JsonAdaptedTransactionTest.java similarity index 76% rename from src/test/java/seedu/address/storage/JsonAdaptedTransactionTest.java rename to src/test/java/unicash/storage/JsonAdaptedTransactionTest.java index 07b7df205e2..d415b7342ab 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedTransactionTest.java +++ b/src/test/java/unicash/storage/JsonAdaptedTransactionTest.java @@ -1,10 +1,9 @@ -package seedu.address.storage; +package unicash.storage; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -import static seedu.address.storage.JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.SHOPPING; +import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.SHOPPING; import java.util.ArrayList; import java.util.List; @@ -12,14 +11,15 @@ import org.junit.jupiter.api.Test; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; -import seedu.address.testutil.TransactionBuilder; +import unicash.commons.exceptions.IllegalValueException; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; +import unicash.testutil.TransactionBuilder; +import unicash.testutil.Assert; public class JsonAdaptedTransactionTest { private static final String INVALID_NAME = "R@chel"; @@ -55,7 +55,7 @@ public void toModelType_invalidName_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Name.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -69,8 +69,8 @@ public void toModelType_nullName_throwsIllegalValueException() { VALID_CATEGORIES ); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + String expectedMessage = String.format(JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -84,7 +84,7 @@ public void toModelType_invalidAmount_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Amount.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -99,7 +99,7 @@ public void toModelType_invalidCategories_throwsIllegalValueException() { VALID_LOCATION, VALID_TYPE, invalidCategories); - assertThrows(IllegalValueException.class, transaction::toModelType); + Assert.assertThrows(IllegalValueException.class, transaction::toModelType); } @Test @@ -139,7 +139,7 @@ public void toModelType_invalidDateTime_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = DateTime.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -152,8 +152,8 @@ public void toModelType_nullDateTime_throwsIllegalValueException() { VALID_TYPE, VALID_CATEGORIES ); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, DateTime.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + String expectedMessage = String.format(JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT, DateTime.class.getSimpleName()); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -167,7 +167,7 @@ public void toModelType_invalidLocation_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Location.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -181,7 +181,7 @@ public void toModelType_invalidType_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Type.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -194,7 +194,7 @@ public void toModelType_nullType_throwsIllegalValueException() { null, VALID_CATEGORIES ); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Type.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + String expectedMessage = String.format(JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT, Type.class.getSimpleName()); + Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } } diff --git a/src/test/java/seedu/address/storage/JsonSerializableUniCashTest.java b/src/test/java/unicash/storage/JsonSerializableUniCashTest.java similarity index 85% rename from src/test/java/seedu/address/storage/JsonSerializableUniCashTest.java rename to src/test/java/unicash/storage/JsonSerializableUniCashTest.java index 46d821b297f..faacae94731 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableUniCashTest.java +++ b/src/test/java/unicash/storage/JsonSerializableUniCashTest.java @@ -1,18 +1,18 @@ -package seedu.address.storage; +package unicash.storage; import static org.junit.jupiter.api.Assertions.assertEquals; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.nio.file.Path; import java.nio.file.Paths; import org.junit.jupiter.api.Test; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.UniCash; -import seedu.address.model.util.SampleDataUtil; +import unicash.commons.exceptions.IllegalValueException; +import unicash.commons.util.JsonUtil; +import unicash.model.ReadOnlyUniCash; +import unicash.model.UniCash; +import unicash.model.util.SampleDataUtil; public class JsonSerializableUniCashTest { diff --git a/src/test/java/seedu/address/storage/JsonUniCashStorageTest.java b/src/test/java/unicash/storage/JsonUniCashStorageTest.java similarity index 89% rename from src/test/java/seedu/address/storage/JsonUniCashStorageTest.java rename to src/test/java/unicash/storage/JsonUniCashStorageTest.java index 6e62b78b3e7..a5156edf179 100644 --- a/src/test/java/seedu/address/storage/JsonUniCashStorageTest.java +++ b/src/test/java/unicash/storage/JsonUniCashStorageTest.java @@ -1,11 +1,11 @@ -package seedu.address.storage; +package unicash.storage; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalTransactions.BUYING_GROCERIES; -import static seedu.address.testutil.TypicalTransactions.INTERN; -import static seedu.address.testutil.TypicalTransactions.getTypicalUniCash; +import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.BUYING_GROCERIES; +import static unicash.testutil.TypicalTransactions.INTERN; +import static unicash.testutil.TypicalTransactions.getTypicalUniCash; import java.io.IOException; import java.nio.file.Path; @@ -14,9 +14,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyUniCash; -import seedu.address.model.UniCash; +import unicash.commons.exceptions.DataLoadingException; +import unicash.model.ReadOnlyUniCash; +import unicash.model.UniCash; public class JsonUniCashStorageTest { private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonUniCashStorageTest"); diff --git a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java b/src/test/java/unicash/storage/JsonUserPrefsStorageTest.java similarity index 86% rename from src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java rename to src/test/java/unicash/storage/JsonUserPrefsStorageTest.java index 4023638e5b1..13211c76de5 100644 --- a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java +++ b/src/test/java/unicash/storage/JsonUserPrefsStorageTest.java @@ -1,8 +1,8 @@ -package seedu.address.storage; +package unicash.storage; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.io.IOException; import java.nio.file.Path; @@ -12,9 +12,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.commons.core.GuiSettings; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.UserPrefs; +import unicash.commons.core.GuiSettings; +import unicash.commons.exceptions.DataLoadingException; +import unicash.model.UserPrefs; +import unicash.testutil.Assert; public class JsonUserPrefsStorageTest { @@ -25,7 +26,7 @@ public class JsonUserPrefsStorageTest { @Test public void readUserPrefs_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> readUserPrefs(null)); + Assert.assertThrows(NullPointerException.class, () -> readUserPrefs(null)); } private Optional readUserPrefs(String userPrefsFileInTestDataFolder) throws DataLoadingException { @@ -40,7 +41,7 @@ public void readUserPrefs_missingFile_emptyResult() throws DataLoadingException @Test public void readUserPrefs_notJsonFormat_exceptionThrown() { - assertThrows(DataLoadingException.class, () -> readUserPrefs("NotJsonFormatUserPrefs.json")); + Assert.assertThrows(DataLoadingException.class, () -> readUserPrefs("NotJsonFormatUserPrefs.json")); } private Path addToTestDataPathIfNotNull(String userPrefsFileInTestDataFolder) { @@ -79,12 +80,12 @@ private UserPrefs getTypicalUserPrefs() { @Test public void savePrefs_nullPrefs_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveUserPrefs(null, "SomeFile.json")); + Assert.assertThrows(NullPointerException.class, () -> saveUserPrefs(null, "SomeFile.json")); } @Test public void saveUserPrefs_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveUserPrefs(new UserPrefs(), null)); + Assert.assertThrows(NullPointerException.class, () -> saveUserPrefs(new UserPrefs(), null)); } /** diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/unicash/storage/StorageManagerTest.java similarity index 87% rename from src/test/java/seedu/address/storage/StorageManagerTest.java rename to src/test/java/unicash/storage/StorageManagerTest.java index a49a354b278..54805f223f0 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/unicash/storage/StorageManagerTest.java @@ -1,18 +1,19 @@ -package seedu.address.storage; +package unicash.storage; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.nio.file.Path; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.commons.core.GuiSettings; -import seedu.address.model.UniCash; -import seedu.address.model.UserPrefs; -import seedu.address.testutil.TypicalTransactions; +import unicash.commons.core.GuiSettings; +import unicash.model.UniCash; +import unicash.model.UserPrefs; +import unicash.testutil.TypicalTransactions; public class StorageManagerTest { @@ -56,7 +57,7 @@ public void addressBookReadSave() throws Exception { var original = TypicalTransactions.getTypicalUniCash(); storageManager.saveUniCash(original); var retrieved = storageManager.readUniCash().get(); - assertEquals(original, new UniCash(retrieved)); + Assertions.assertEquals(original, new UniCash(retrieved)); } @Test diff --git a/src/test/java/seedu/address/testutil/Assert.java b/src/test/java/unicash/testutil/Assert.java similarity index 97% rename from src/test/java/seedu/address/testutil/Assert.java rename to src/test/java/unicash/testutil/Assert.java index 4eb62a7f9aa..0cc8bd964c3 100644 --- a/src/test/java/seedu/address/testutil/Assert.java +++ b/src/test/java/unicash/testutil/Assert.java @@ -1,4 +1,4 @@ -package seedu.address.testutil; +package unicash.testutil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.function.Executable; diff --git a/src/test/java/seedu/address/testutil/EditTransactionDescriptorBuilder.java b/src/test/java/unicash/testutil/EditTransactionDescriptorBuilder.java similarity index 87% rename from src/test/java/seedu/address/testutil/EditTransactionDescriptorBuilder.java rename to src/test/java/unicash/testutil/EditTransactionDescriptorBuilder.java index fc2394b9e43..abd95705b77 100644 --- a/src/test/java/seedu/address/testutil/EditTransactionDescriptorBuilder.java +++ b/src/test/java/unicash/testutil/EditTransactionDescriptorBuilder.java @@ -1,17 +1,17 @@ -package seedu.address.testutil; +package unicash.testutil; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import seedu.address.logic.commands.EditTransactionCommand; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; +import unicash.logic.commands.EditTransactionCommand; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; /** * A utility class to help with building EditTransactionDescriptor objects. diff --git a/src/test/java/seedu/address/testutil/SerializableTestClass.java b/src/test/java/unicash/testutil/SerializableTestClass.java similarity index 98% rename from src/test/java/seedu/address/testutil/SerializableTestClass.java rename to src/test/java/unicash/testutil/SerializableTestClass.java index f5a66340489..6a1f585539f 100644 --- a/src/test/java/seedu/address/testutil/SerializableTestClass.java +++ b/src/test/java/unicash/testutil/SerializableTestClass.java @@ -1,4 +1,4 @@ -package seedu.address.testutil; +package unicash.testutil; import java.time.LocalDateTime; import java.util.ArrayList; diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/unicash/testutil/TestUtil.java similarity index 90% rename from src/test/java/seedu/address/testutil/TestUtil.java rename to src/test/java/unicash/testutil/TestUtil.java index e97ad47f0ee..785adc4c2e7 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/unicash/testutil/TestUtil.java @@ -1,13 +1,13 @@ -package seedu.address.testutil; +package unicash.testutil; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import seedu.address.commons.core.index.Index; -import seedu.address.model.Model; -import seedu.address.model.transaction.Transaction; +import unicash.commons.core.index.Index; +import unicash.model.Model; +import unicash.model.transaction.Transaction; /** * A utility class for test cases. diff --git a/src/test/java/seedu/address/testutil/TransactionBuilder.java b/src/test/java/unicash/testutil/TransactionBuilder.java similarity index 88% rename from src/test/java/seedu/address/testutil/TransactionBuilder.java rename to src/test/java/unicash/testutil/TransactionBuilder.java index 7c22048599f..fa5b0f0baee 100644 --- a/src/test/java/seedu/address/testutil/TransactionBuilder.java +++ b/src/test/java/unicash/testutil/TransactionBuilder.java @@ -1,16 +1,16 @@ -package seedu.address.testutil; +package unicash.testutil; import java.util.HashSet; import java.util.Set; -import seedu.address.model.category.Category; -import seedu.address.model.transaction.Amount; -import seedu.address.model.transaction.DateTime; -import seedu.address.model.transaction.Location; -import seedu.address.model.transaction.Name; -import seedu.address.model.transaction.Transaction; -import seedu.address.model.transaction.Type; -import seedu.address.model.util.SampleDataUtil; +import unicash.model.category.Category; +import unicash.model.transaction.Amount; +import unicash.model.transaction.DateTime; +import unicash.model.transaction.Location; +import unicash.model.transaction.Name; +import unicash.model.transaction.Transaction; +import unicash.model.transaction.Type; +import unicash.model.util.SampleDataUtil; /** * A utility class to help with building Transaction objects. diff --git a/src/test/java/unicash/testutil/TransactionUtil.java b/src/test/java/unicash/testutil/TransactionUtil.java new file mode 100644 index 00000000000..a336c609249 --- /dev/null +++ b/src/test/java/unicash/testutil/TransactionUtil.java @@ -0,0 +1,61 @@ +package unicash.testutil; + +import java.util.Set; + +import unicash.logic.commands.AddTransactionCommand; +import unicash.logic.commands.EditTransactionCommand; +import unicash.model.category.Category; +import unicash.model.transaction.Transaction; +import unicash.logic.parser.CliSyntax; + +/** + * A utility class for Transaction. + */ +public class TransactionUtil { + + /** + * Returns an add command string for adding the {@code transaction}. + */ + public static String getAddTransactionCommand(Transaction transaction) { + return AddTransactionCommand.COMMAND_WORD + " " + getTransactionDetails(transaction); + } + + /** + * Returns the part of command string for the given {@code transaction}'s details. + */ + public static String getTransactionDetails(Transaction transaction) { + StringBuilder sb = new StringBuilder(); + sb.append(CliSyntax.PREFIX_NAME).append(transaction.getName().fullName).append(" "); + sb.append(CliSyntax.PREFIX_TYPE).append(transaction.getType().type.getOriginalString()).append(" "); + sb.append(CliSyntax.PREFIX_AMOUNT).append(transaction.getAmount().toString()).append(" "); + sb.append(CliSyntax.PREFIX_DATETIME).append(transaction.getDateTime().originalString()).append(" "); + sb.append(CliSyntax.PREFIX_LOCATION).append(transaction.getLocation().location).append(" "); + transaction.getCategories().forEach( + category -> sb.append(CliSyntax.PREFIX_CATEGORY).append(category.category).append(" ") + ); + return sb.toString(); + } + + public static String getEditTransactionDescriptorDetails(EditTransactionCommand.EditTransactionDescriptor descriptor) { + StringBuilder sb = new StringBuilder(); + descriptor.getName().ifPresent(name -> sb.append(CliSyntax.PREFIX_NAME).append(name.fullName) + .append(" ")); + descriptor.getType().ifPresent(type -> sb.append(CliSyntax.PREFIX_TYPE).append(type.type.getOriginalString()) + .append(" ")); + descriptor.getAmount().ifPresent(amount -> sb.append(CliSyntax.PREFIX_AMOUNT).append(amount.amount) + .append(" ")); + descriptor.getLocation().ifPresent(location -> sb.append(CliSyntax.PREFIX_LOCATION).append(location) + .append(" ")); + descriptor.getDateTime().ifPresent(dateTime -> sb.append(CliSyntax.PREFIX_DATETIME).append(dateTime.originalString()) + .append(" ")); + if (descriptor.getCategories().isPresent()) { + Set categories = descriptor.getCategories().get(); + if (categories.isEmpty()) { + sb.append(CliSyntax.PREFIX_CATEGORY); + } else { + categories.forEach(s -> sb.append(CliSyntax.PREFIX_CATEGORY).append(s.category).append(" ")); + } + } + return sb.toString(); + } +} diff --git a/src/test/java/seedu/address/testutil/TypicalIndexes.java b/src/test/java/unicash/testutil/TypicalIndexes.java similarity index 88% rename from src/test/java/seedu/address/testutil/TypicalIndexes.java rename to src/test/java/unicash/testutil/TypicalIndexes.java index 8afed4bdb8f..2f477c27dfe 100644 --- a/src/test/java/seedu/address/testutil/TypicalIndexes.java +++ b/src/test/java/unicash/testutil/TypicalIndexes.java @@ -1,6 +1,6 @@ -package seedu.address.testutil; +package unicash.testutil; -import seedu.address.commons.core.index.Index; +import unicash.commons.core.index.Index; /** * A utility class containing a list of {@code Index} objects to be used in tests. diff --git a/src/test/java/unicash/testutil/TypicalTransactions.java b/src/test/java/unicash/testutil/TypicalTransactions.java new file mode 100644 index 00000000000..5571a1f0f22 --- /dev/null +++ b/src/test/java/unicash/testutil/TypicalTransactions.java @@ -0,0 +1,73 @@ +package unicash.testutil; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import unicash.model.UniCash; +import unicash.model.transaction.Transaction; +import unicash.logic.commands.CommandTestUtil; + +/** + * A utility class containing a list of {@code Transaction} objects to be used in tests. + */ +public class TypicalTransactions { + public static final Transaction BUYING_GROCERIES = new TransactionBuilder() + .withName("Buying groceries") + .withAmount(16.75) + .withLocation("Sheng Shiong (UTown)") + .withCategories("Groceries") + .build(); + + public static final Transaction DINING_WITH_FRIENDS = new TransactionBuilder() + .withName("End of Semester Celebration") + .withAmount(234.50) + .withLocation("Poulet") + .withDateTime("18-08-2001 18:18") + .withCategories("Food") + .build(); + + public static final Transaction WORK_AT_LIHO = new TransactionBuilder() + .withName("Working at liho") + .withType("income") + .withAmount(888) + .withDateTime("18-09-2002 18:17") + .build(); + + // Manually added - Income's details found in {@code CommandTestUtil} + public static final Transaction NUS = new TransactionBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS) + .withType(CommandTestUtil.VALID_TYPE_EXPENSE) + .withAmount(CommandTestUtil.VALID_AMOUNT_NUS) + .withDateTime(CommandTestUtil.VALID_DATETIME_NUS) + .withLocation(CommandTestUtil.VALID_LOCATION_NUS) + .withCategories(CommandTestUtil.VALID_CATEGORY_NUS) + .build(); + public static final Transaction INTERN = new TransactionBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_INTERN) + .withType(CommandTestUtil.VALID_TYPE_EXPENSE) + .withAmount(CommandTestUtil.VALID_AMOUNT_INTERN) + .withDateTime(CommandTestUtil.VALID_DATETIME_INTERN) + .withLocation(CommandTestUtil.VALID_LOCATION_ORCHARD) + .build(); + + public static final Transaction SHOPPING = new TransactionBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_SHOPPING) + .withType(CommandTestUtil.VALID_TYPE_INCOME) + .withAmount(CommandTestUtil.VALID_AMOUNT_SHOPPING) + .withDateTime(CommandTestUtil.VALID_DATETIME_SHOPPING) + .withLocation(CommandTestUtil.VALID_LOCATION_ORCHARD) + .withCategories(CommandTestUtil.VALID_CATEGORY_ENTERTAINMENT, CommandTestUtil.VALID_CATEGORY_EDUCATION) + .build(); + /** + * Returns a {@code UniCash} with all the typical transactions. + */ + public static UniCash getTypicalUniCash() { + UniCash ab = new UniCash(); + for (Transaction transaction : getTypicalTransactions()) { + ab.addTransaction(transaction); + } + return ab; + } + + public static List getTypicalTransactions() { + return new ArrayList<>(Arrays.asList(BUYING_GROCERIES, DINING_WITH_FRIENDS, WORK_AT_LIHO, NUS, INTERN)); + } +} diff --git a/src/test/java/seedu/address/testutil/UniCashBuilder.java b/src/test/java/unicash/testutil/UniCashBuilder.java similarity index 85% rename from src/test/java/seedu/address/testutil/UniCashBuilder.java rename to src/test/java/unicash/testutil/UniCashBuilder.java index 0e9e5bbfd18..9d5baee7ab0 100644 --- a/src/test/java/seedu/address/testutil/UniCashBuilder.java +++ b/src/test/java/unicash/testutil/UniCashBuilder.java @@ -1,7 +1,7 @@ -package seedu.address.testutil; +package unicash.testutil; -import seedu.address.model.UniCash; -import seedu.address.model.transaction.Transaction; +import unicash.model.UniCash; +import unicash.model.transaction.Transaction; /** * A utility class to help with building UniCash objects. diff --git a/src/test/java/seedu/address/ui/TestFxmlObject.java b/src/test/java/unicash/ui/TestFxmlObject.java similarity index 97% rename from src/test/java/seedu/address/ui/TestFxmlObject.java rename to src/test/java/unicash/ui/TestFxmlObject.java index 93f40f1276a..ead01a1f433 100644 --- a/src/test/java/seedu/address/ui/TestFxmlObject.java +++ b/src/test/java/unicash/ui/TestFxmlObject.java @@ -1,4 +1,4 @@ -package seedu.address.ui; +package unicash.ui; import java.util.Objects; diff --git a/src/test/java/seedu/address/ui/UiPartTest.java b/src/test/java/unicash/ui/UiPartTest.java similarity index 68% rename from src/test/java/seedu/address/ui/UiPartTest.java rename to src/test/java/unicash/ui/UiPartTest.java index 33d82d911b8..a599d5ce5ba 100644 --- a/src/test/java/seedu/address/ui/UiPartTest.java +++ b/src/test/java/unicash/ui/UiPartTest.java @@ -1,8 +1,8 @@ -package seedu.address.ui; +package unicash.ui; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static seedu.address.testutil.Assert.assertThrows; +import static unicash.testutil.Assert.assertThrows; import java.net.URL; import java.nio.file.Path; @@ -11,7 +11,8 @@ import org.junit.jupiter.api.io.TempDir; import javafx.fxml.FXML; -import seedu.address.MainApp; +import unicash.MainApp; +import unicash.testutil.Assert; public class UiPartTest { @@ -26,22 +27,22 @@ public class UiPartTest { @Test public void constructor_nullFileUrl_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null)); - assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null, new Object())); + Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null)); + Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null, new Object())); } @Test public void constructor_missingFileUrl_throwsAssertionError() throws Exception { URL missingFileUrl = new URL(testFolder.toUri().toURL(), MISSING_FILE_PATH); - assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl)); - assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl, new Object())); + Assert.assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl)); + Assert.assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl, new Object())); } @Test public void constructor_invalidFileUrl_throwsAssertionError() { URL invalidFileUrl = getTestFileUrl(INVALID_FILE_PATH); - assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl)); - assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl, new Object())); + Assert.assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl)); + Assert.assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl, new Object())); } @Test @@ -59,20 +60,20 @@ public void constructor_validFileWithFxRootUrl_loadsFile() { @Test public void constructor_nullFileName_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new TestUiPart((String) null)); - assertThrows(NullPointerException.class, () -> new TestUiPart((String) null, new Object())); + Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((String) null)); + Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((String) null, new Object())); } @Test public void constructor_missingFileName_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH)); - assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH, new Object())); + Assert.assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH)); + Assert.assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH, new Object())); } @Test public void constructor_invalidFileName_throwsAssertionError() { - assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH)); - assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH, new Object())); + Assert.assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH)); + Assert.assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH, new Object())); } private URL getTestFileUrl(String testFilePath) { diff --git a/src/test/resources/view/UiPartTest/validFile.fxml b/src/test/resources/view/UiPartTest/validFile.fxml index bab836af0db..6552d9beef8 100644 --- a/src/test/resources/view/UiPartTest/validFile.fxml +++ b/src/test/resources/view/UiPartTest/validFile.fxml @@ -1,4 +1,4 @@ - + Hello World! diff --git a/src/test/resources/view/UiPartTest/validFileWithFxRoot.fxml b/src/test/resources/view/UiPartTest/validFileWithFxRoot.fxml index 1a8b2c9e4d3..6465bb1b26f 100644 --- a/src/test/resources/view/UiPartTest/validFileWithFxRoot.fxml +++ b/src/test/resources/view/UiPartTest/validFileWithFxRoot.fxml @@ -1,6 +1,6 @@ - + Hello World! From 1b4b46c5d9063a604359d2dfdc52d8bfdbb666f9 Mon Sep 17 00:00:00 2001 From: Rubesh S Date: Tue, 17 Oct 2023 20:46:47 +0800 Subject: [PATCH 2/5] Fix import order --- .../java/unicash/logic/commands/AddTransactionCommand.java | 3 ++- .../java/unicash/logic/parser/AddTransactionCommandParser.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/unicash/logic/commands/AddTransactionCommand.java b/src/main/java/unicash/logic/commands/AddTransactionCommand.java index f123860fe8a..20e06371aec 100644 --- a/src/main/java/unicash/logic/commands/AddTransactionCommand.java +++ b/src/main/java/unicash/logic/commands/AddTransactionCommand.java @@ -5,9 +5,10 @@ import unicash.commons.util.ToStringBuilder; import unicash.logic.UniCashMessages; import unicash.logic.commands.exceptions.CommandException; +import unicash.logic.parser.CliSyntax; import unicash.model.Model; import unicash.model.transaction.Transaction; -import unicash.logic.parser.CliSyntax; + /** * Adds a transaction to UniCash. diff --git a/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java b/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java index fa4f1307ece..90f5ac001ec 100644 --- a/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java +++ b/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java @@ -3,6 +3,7 @@ import java.util.Set; import java.util.stream.Stream; +import unicash.logic.UniCashMessages; import unicash.logic.commands.AddTransactionCommand; import unicash.logic.parser.exceptions.ParseException; import unicash.model.category.Category; @@ -12,7 +13,7 @@ import unicash.model.transaction.Name; import unicash.model.transaction.Transaction; import unicash.model.transaction.Type; -import unicash.logic.UniCashMessages; + /** * Parses input arguments and creates a new AddTransactionCommand object From 726930d730fca8c1c114a0fd905938100b1d42dc Mon Sep 17 00:00:00 2001 From: Rubesh S Date: Wed, 18 Oct 2023 13:08:48 +0800 Subject: [PATCH 3/5] Fix styling for Main classes --- .../parser/AddTransactionCommandParser.java | 33 +++++++++------ .../java/unicash/logic/parser/CliSyntax.java | 4 -- .../DeleteTransactionCommandParser.java | 6 ++- .../parser/EditTransactionCommandParser.java | 40 +++++++++++-------- .../GetTotalExpenditureCommandParser.java | 13 +++--- src/main/java/unicash/model/ModelManager.java | 5 +-- .../java/unicash/model/category/Category.java | 4 +- .../unicash/model/transaction/Amount.java | 4 +- .../unicash/model/transaction/DateTime.java | 10 ++--- .../unicash/model/transaction/Location.java | 4 +- .../java/unicash/model/transaction/Name.java | 4 +- .../model/transaction/Transaction.java | 3 +- .../model/transaction/TransactionList.java | 5 +-- .../java/unicash/model/transaction/Type.java | 3 +- src/main/java/unicash/ui/CommandBox.java | 2 +- 15 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java b/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java index 90f5ac001ec..cf579f9f863 100644 --- a/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java +++ b/src/main/java/unicash/logic/parser/AddTransactionCommandParser.java @@ -1,9 +1,16 @@ package unicash.logic.parser; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_NAME; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; + import java.util.Set; import java.util.stream.Stream; -import unicash.logic.UniCashMessages; import unicash.logic.commands.AddTransactionCommand; import unicash.logic.parser.exceptions.ParseException; import unicash.model.category.Category; @@ -28,31 +35,31 @@ public class AddTransactionCommandParser implements Parser categoryList = ParserUtil.parseCategories(argMultimap.getAllValues(CliSyntax.PREFIX_CATEGORY)); + Set categoryList = ParserUtil.parseCategories(argMultimap.getAllValues(PREFIX_CATEGORY)); Transaction transaction = new Transaction(name, type, amount, dateTime, location, categoryList); diff --git a/src/main/java/unicash/logic/parser/CliSyntax.java b/src/main/java/unicash/logic/parser/CliSyntax.java index c6c92e1ecb7..082c4834b7f 100644 --- a/src/main/java/unicash/logic/parser/CliSyntax.java +++ b/src/main/java/unicash/logic/parser/CliSyntax.java @@ -7,10 +7,6 @@ public class CliSyntax { /* Prefix definitions */ public static final Prefix PREFIX_NAME = new Prefix("n/"); - public static final Prefix PREFIX_PHONE = new Prefix("p/"); - public static final Prefix PREFIX_EMAIL = new Prefix("e/"); - public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); - public static final Prefix PREFIX_TAG = new Prefix("t/"); public static final Prefix PREFIX_AMOUNT = new Prefix("amt/"); public static final Prefix PREFIX_DATETIME = new Prefix("dt/"); public static final Prefix PREFIX_TYPE = new Prefix("type/"); diff --git a/src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java b/src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java index bec045a81f6..a49770e7d7f 100644 --- a/src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java +++ b/src/main/java/unicash/logic/parser/DeleteTransactionCommandParser.java @@ -1,9 +1,11 @@ package unicash.logic.parser; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; + import unicash.commons.core.index.Index; import unicash.logic.commands.DeleteTransactionCommand; import unicash.logic.parser.exceptions.ParseException; -import unicash.logic.UniCashMessages; + /** * Parses input arguments and creates a new DeleteTransactionCommand object @@ -22,7 +24,7 @@ public DeleteTransactionCommand parse(String args) throws ParseException { return new DeleteTransactionCommand(index); } catch (ParseException pe) { throw new ParseException( - String.format(UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT, DeleteTransactionCommand.MESSAGE_USAGE), pe); + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteTransactionCommand.MESSAGE_USAGE), pe); } } diff --git a/src/main/java/unicash/logic/parser/EditTransactionCommandParser.java b/src/main/java/unicash/logic/parser/EditTransactionCommandParser.java index 843671c7187..51184c6fca8 100644 --- a/src/main/java/unicash/logic/parser/EditTransactionCommandParser.java +++ b/src/main/java/unicash/logic/parser/EditTransactionCommandParser.java @@ -1,6 +1,13 @@ package unicash.logic.parser; import static java.util.Objects.requireNonNull; +import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_NAME; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; import java.util.Collection; import java.util.Collections; @@ -11,7 +18,6 @@ import unicash.logic.commands.EditTransactionCommand; import unicash.logic.parser.exceptions.ParseException; import unicash.model.category.Category; -import unicash.logic.UniCashMessages; /** * Parses input arguments and creates a new EditTransactionCommand object @@ -27,51 +33,51 @@ public class EditTransactionCommandParser implements Parser categories ) { - CollectionUtil.requireAllNonNull(name, type, amount, categories, dateTime, location); + requireAllNonNull(name, type, amount, categories, dateTime, location); this.name = name; this.type = type; this.amount = amount; diff --git a/src/main/java/unicash/model/transaction/TransactionList.java b/src/main/java/unicash/model/transaction/TransactionList.java index ab443794053..8e728fa069e 100644 --- a/src/main/java/unicash/model/transaction/TransactionList.java +++ b/src/main/java/unicash/model/transaction/TransactionList.java @@ -9,7 +9,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import unicash.model.transaction.exceptions.TransactionNotFoundException; -import unicash.commons.util.CollectionUtil; /** * A list of Transactions that does not allow nulls. @@ -42,7 +41,7 @@ public void add(Transaction toAdd) { * {@code target} must exist in the list. */ public void setTransaction(Transaction target, Transaction editedTransaction) { - CollectionUtil.requireAllNonNull(target, editedTransaction); + requireAllNonNull(target, editedTransaction); int index = internalList.indexOf(target); if (index == -1) { @@ -77,7 +76,7 @@ public void setTransactions(TransactionList replacement) { * {@code transactions} must not contain null. */ public void setTransactions(List transactions) { - CollectionUtil.requireAllNonNull(transactions); + requireAllNonNull(transactions); internalList.setAll(transactions); } diff --git a/src/main/java/unicash/model/transaction/Type.java b/src/main/java/unicash/model/transaction/Type.java index 547a1fa7d5e..92473ea6a65 100644 --- a/src/main/java/unicash/model/transaction/Type.java +++ b/src/main/java/unicash/model/transaction/Type.java @@ -4,7 +4,6 @@ import static unicash.commons.util.AppUtil.checkArgument; import unicash.commons.enums.TransactionType; -import unicash.commons.util.AppUtil; /** * Represents a Transaction's type. @@ -23,7 +22,7 @@ public class Type { */ public Type(String type) { requireNonNull(type); - AppUtil.checkArgument(isValidType(type), MESSAGE_CONSTRAINTS); + checkArgument(isValidType(type), MESSAGE_CONSTRAINTS); this.type = TransactionType.parseType(type); } diff --git a/src/main/java/unicash/ui/CommandBox.java b/src/main/java/unicash/ui/CommandBox.java index 6c3f5df54ab..06cdc57c629 100644 --- a/src/main/java/unicash/ui/CommandBox.java +++ b/src/main/java/unicash/ui/CommandBox.java @@ -4,10 +4,10 @@ import javafx.fxml.FXML; import javafx.scene.control.TextField; import javafx.scene.layout.Region; +import unicash.logic.Logic; import unicash.logic.commands.CommandResult; import unicash.logic.commands.exceptions.CommandException; import unicash.logic.parser.exceptions.ParseException; -import unicash.logic.Logic; /** * The UI component that is responsible for receiving user command inputs. From 10d51d308e8b825d83a5c1c6535517212b92051e Mon Sep 17 00:00:00 2001 From: Rubesh S Date: Wed, 18 Oct 2023 16:13:44 +0800 Subject: [PATCH 4/5] Fix style --- .../unicash/commons/core/VersionTest.java | 4 +- .../unicash/commons/core/index/IndexTest.java | 5 +- .../unicash/commons/util/AppUtilTest.java | 8 +- .../commons/util/CollectionUtilTest.java | 9 +- .../unicash/commons/util/ConfigUtilTest.java | 9 +- .../unicash/commons/util/FileUtilTest.java | 3 +- .../unicash/commons/util/StringUtilTest.java | 12 +-- .../java/unicash/logic/LogicManagerTest.java | 27 +++--- .../commands/AddTransactionCommandTest.java | 9 +- .../ClearTransactionsCommandTest.java | 9 +- .../logic/commands/CommandTestUtil.java | 48 +++++----- .../DeleteTransactionCommandTest.java | 43 +++++---- .../commands/EditTransactionCommandTest.java | 95 ++++++++++--------- .../commands/ExitCommandUniCashTest.java | 2 +- .../GetTotalExpenditureCommandTest.java | 16 ++-- .../logic/commands/ListCommandTest.java | 2 +- .../AddTransactionCommandParserTest.java | 49 +++++----- .../logic/parser/AddressBookParserTest.java | 15 ++- .../logic/parser/CommandParserTestUtil.java | 3 +- .../EditTransactionCommandParserTest.java | 28 +++--- .../unicash/logic/parser/ParserUtilTest.java | 59 ++++++------ .../java/unicash/model/ModelManagerTest.java | 23 +++-- .../java/unicash/model/UserPrefsTest.java | 5 +- .../unicash/model/transaction/AmountTest.java | 3 +- .../model/transaction/DateTimeTest.java | 7 +- 25 files changed, 255 insertions(+), 238 deletions(-) diff --git a/src/test/java/unicash/commons/core/VersionTest.java b/src/test/java/unicash/commons/core/VersionTest.java index 84b4049a178..052a3d3bc2c 100644 --- a/src/test/java/unicash/commons/core/VersionTest.java +++ b/src/test/java/unicash/commons/core/VersionTest.java @@ -7,7 +7,7 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; + public class VersionTest { @@ -20,7 +20,7 @@ public void versionParsing_acceptableVersionString_parsedVersionCorrectly() { @Test public void versionParsing_wrongVersionString_throwIllegalArgumentException() { - Assert.assertThrows(IllegalArgumentException.class, () -> Version.fromString("This is not a version string")); + assertThrows(IllegalArgumentException.class, () -> Version.fromString("This is not a version string")); } @Test diff --git a/src/test/java/unicash/commons/core/index/IndexTest.java b/src/test/java/unicash/commons/core/index/IndexTest.java index c10e36df935..8f7d9c1af29 100644 --- a/src/test/java/unicash/commons/core/index/IndexTest.java +++ b/src/test/java/unicash/commons/core/index/IndexTest.java @@ -6,14 +6,13 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; public class IndexTest { @Test public void createOneBasedIndex() { // invalid index - Assert.assertThrows(IndexOutOfBoundsException.class, () -> Index.fromOneBased(0)); + assertThrows(IndexOutOfBoundsException.class, () -> Index.fromOneBased(0)); // check equality using the same base assertEquals(1, Index.fromOneBased(1).getOneBased()); @@ -27,7 +26,7 @@ public void createOneBasedIndex() { @Test public void createZeroBasedIndex() { // invalid index - Assert.assertThrows(IndexOutOfBoundsException.class, () -> Index.fromZeroBased(-1)); + assertThrows(IndexOutOfBoundsException.class, () -> Index.fromZeroBased(-1)); // check equality using the same base assertEquals(0, Index.fromZeroBased(0).getZeroBased()); diff --git a/src/test/java/unicash/commons/util/AppUtilTest.java b/src/test/java/unicash/commons/util/AppUtilTest.java index 33f43c9232b..1b81ce996e1 100644 --- a/src/test/java/unicash/commons/util/AppUtilTest.java +++ b/src/test/java/unicash/commons/util/AppUtilTest.java @@ -4,7 +4,7 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; + public class AppUtilTest { @@ -15,7 +15,7 @@ public void getImage_exitingImage() { @Test public void getImage_nullGiven_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> AppUtil.getImage(null)); + assertThrows(NullPointerException.class, () -> AppUtil.getImage(null)); } @Test @@ -26,12 +26,12 @@ public void checkArgument_true_nothingHappens() { @Test public void checkArgument_falseWithoutErrorMessage_throwsIllegalArgumentException() { - Assert.assertThrows(IllegalArgumentException.class, () -> AppUtil.checkArgument(false)); + assertThrows(IllegalArgumentException.class, () -> AppUtil.checkArgument(false)); } @Test public void checkArgument_falseWithErrorMessage_throwsIllegalArgumentException() { String errorMessage = "error message"; - Assert.assertThrows(IllegalArgumentException.class, errorMessage, () -> AppUtil.checkArgument(false, errorMessage)); + assertThrows(IllegalArgumentException.class, errorMessage, () -> AppUtil.checkArgument(false, errorMessage)); } } diff --git a/src/test/java/unicash/commons/util/CollectionUtilTest.java b/src/test/java/unicash/commons/util/CollectionUtilTest.java index 3da5b3facf7..c26415e6151 100644 --- a/src/test/java/unicash/commons/util/CollectionUtilTest.java +++ b/src/test/java/unicash/commons/util/CollectionUtilTest.java @@ -11,7 +11,6 @@ import java.util.List; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; public class CollectionUtilTest { @Test @@ -88,7 +87,7 @@ public void isAnyNonNull() { * if {@code objects} or any element of {@code objects} is null. */ private void assertNullPointerExceptionThrown(Object... objects) { - Assert.assertThrows(NullPointerException.class, () -> CollectionUtil.requireAllNonNull(objects)); + assertThrows(NullPointerException.class, () -> requireAllNonNull(objects)); } /** @@ -96,14 +95,14 @@ private void assertNullPointerExceptionThrown(Object... objects) { * if {@code collection} or any element of {@code collection} is null. */ private void assertNullPointerExceptionThrown(Collection collection) { - Assert.assertThrows(NullPointerException.class, () -> CollectionUtil.requireAllNonNull(collection)); + assertThrows(NullPointerException.class, () -> requireAllNonNull(collection)); } private void assertNullPointerExceptionNotThrown(Object... objects) { - CollectionUtil.requireAllNonNull(objects); + requireAllNonNull(objects); } private void assertNullPointerExceptionNotThrown(Collection collection) { - CollectionUtil.requireAllNonNull(collection); + requireAllNonNull(collection); } } diff --git a/src/test/java/unicash/commons/util/ConfigUtilTest.java b/src/test/java/unicash/commons/util/ConfigUtilTest.java index afcff984d1d..3ec37a16042 100644 --- a/src/test/java/unicash/commons/util/ConfigUtilTest.java +++ b/src/test/java/unicash/commons/util/ConfigUtilTest.java @@ -15,7 +15,6 @@ import unicash.commons.core.Config; import unicash.commons.exceptions.DataLoadingException; -import unicash.testutil.Assert; public class ConfigUtilTest { @@ -26,7 +25,7 @@ public class ConfigUtilTest { @Test public void read_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> read(null)); + assertThrows(NullPointerException.class, () -> read(null)); } @Test @@ -36,7 +35,7 @@ public void read_missingFile_emptyResult() throws DataLoadingException { @Test public void read_notJsonFormat_exceptionThrown() { - Assert.assertThrows(DataLoadingException.class, () -> read("NotJsonFormatConfig.json")); + assertThrows(DataLoadingException.class, () -> read("NotJsonFormatConfig.json")); } @Test @@ -76,12 +75,12 @@ private Optional read(String configFileInTestDataFolder) throws DataLoad @Test public void save_nullConfig_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> save(null, "SomeFile.json")); + assertThrows(NullPointerException.class, () -> save(null, "SomeFile.json")); } @Test public void save_nullFile_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> save(new Config(), null)); + assertThrows(NullPointerException.class, () -> save(new Config(), null)); } @Test diff --git a/src/test/java/unicash/commons/util/FileUtilTest.java b/src/test/java/unicash/commons/util/FileUtilTest.java index 8e9cb82e77c..bb5b9c1e7da 100644 --- a/src/test/java/unicash/commons/util/FileUtilTest.java +++ b/src/test/java/unicash/commons/util/FileUtilTest.java @@ -10,7 +10,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import unicash.testutil.Assert; public class FileUtilTest { @@ -26,7 +25,7 @@ public void isValidPath() { assertFalse(FileUtil.isValidPath("a\0")); // null path -> throws NullPointerException - Assert.assertThrows(NullPointerException.class, () -> FileUtil.isValidPath(null)); + assertThrows(NullPointerException.class, () -> FileUtil.isValidPath(null)); } @Test diff --git a/src/test/java/unicash/commons/util/StringUtilTest.java b/src/test/java/unicash/commons/util/StringUtilTest.java index 936ec6fabb8..33bea02bf2d 100644 --- a/src/test/java/unicash/commons/util/StringUtilTest.java +++ b/src/test/java/unicash/commons/util/StringUtilTest.java @@ -7,7 +7,7 @@ import java.io.FileNotFoundException; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; + public class StringUtilTest { @@ -57,24 +57,24 @@ public void isNonZeroUnsignedInteger() { @Test public void containsWordIgnoreCase_nullWord_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase("typical sentence", null)); + assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase("typical sentence", null)); } @Test public void containsWordIgnoreCase_emptyWord_throwsIllegalArgumentException() { - Assert.assertThrows(IllegalArgumentException.class, "Word parameter cannot be empty", () + assertThrows(IllegalArgumentException.class, "Word parameter cannot be empty", () -> StringUtil.containsWordIgnoreCase("typical sentence", " ")); } @Test public void containsWordIgnoreCase_multipleWords_throwsIllegalArgumentException() { - Assert.assertThrows(IllegalArgumentException.class, "Word parameter should be a single word", () + assertThrows(IllegalArgumentException.class, "Word parameter should be a single word", () -> StringUtil.containsWordIgnoreCase("typical sentence", "aaa BBB")); } @Test public void containsWordIgnoreCase_nullSentence_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase(null, "abc")); + assertThrows(NullPointerException.class, () -> StringUtil.containsWordIgnoreCase(null, "abc")); } /* @@ -138,7 +138,7 @@ public void getDetails_exceptionGiven() { @Test public void getDetails_nullGiven_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> StringUtil.getDetails(null)); + assertThrows(NullPointerException.class, () -> StringUtil.getDetails(null)); } } diff --git a/src/test/java/unicash/logic/LogicManagerTest.java b/src/test/java/unicash/logic/LogicManagerTest.java index 681bf630784..02ac5a0a45f 100644 --- a/src/test/java/unicash/logic/LogicManagerTest.java +++ b/src/test/java/unicash/logic/LogicManagerTest.java @@ -3,6 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static unicash.logic.UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX; import static unicash.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; +import static unicash.logic.commands.CommandTestUtil.AMOUNT_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.CATEGORY_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.DATETIME_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.LOCATION_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.TRANSACTION_NAME_DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.TYPE_DESC_EXPENSE; import static unicash.testutil.Assert.assertThrows; import static unicash.testutil.TypicalTransactions.NUS; @@ -10,7 +16,6 @@ import java.nio.file.AccessDeniedException; import java.nio.file.Path; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -31,8 +36,6 @@ import unicash.storage.JsonUserPrefsStorage; import unicash.storage.StorageManager; import unicash.testutil.TransactionBuilder; -import unicash.logic.commands.CommandTestUtil; -import unicash.testutil.Assert; public class LogicManagerTest { private static final IOException DUMMY_IO_EXCEPTION = new IOException("dummy IO exception"); @@ -85,12 +88,12 @@ public void execute_storageThrowsAdException_throwsCommandException() { @Test public void getFilteredTransactionList_modifyList_throwsUnsupportedOperationException() { - Assert.assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredTransactionList().remove(0)); + assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredTransactionList().remove(0)); } @Test public void getGuiSettings() { - Assertions.assertEquals(model.getGuiSettings(), new GuiSettings()); + assertEquals(model.getGuiSettings(), new GuiSettings()); } @Test @@ -155,7 +158,7 @@ private void assertCommandFailure(String inputCommand, Class expectedException, String expectedMessage, Model expectedModel) { - Assert.assertThrows(expectedException, expectedMessage, () -> logic.execute(inputCommand)); + assertThrows(expectedException, expectedMessage, () -> logic.execute(inputCommand)); assertEquals(expectedModel, model); } @@ -185,12 +188,12 @@ public void saveUniCash(ReadOnlyUniCash uniCash, Path filePath) // Triggers the saveUniCash method by executing an add command String addCommand = AddTransactionCommand.COMMAND_WORD - + CommandTestUtil.TRANSACTION_NAME_DESC_NUS - + CommandTestUtil.CATEGORY_DESC_NUS - + CommandTestUtil.AMOUNT_DESC_NUS - + CommandTestUtil.DATETIME_DESC_NUS - + CommandTestUtil.TYPE_DESC_EXPENSE - + CommandTestUtil.LOCATION_DESC_NUS; + + TRANSACTION_NAME_DESC_NUS + + CATEGORY_DESC_NUS + + AMOUNT_DESC_NUS + + DATETIME_DESC_NUS + + TYPE_DESC_EXPENSE + + LOCATION_DESC_NUS; Transaction expectedTransaction = new TransactionBuilder(NUS).build(); ModelManager expectedModel = new ModelManager(); expectedModel.addTransaction(expectedTransaction); diff --git a/src/test/java/unicash/logic/commands/AddTransactionCommandTest.java b/src/test/java/unicash/logic/commands/AddTransactionCommandTest.java index 649290a4f94..25c3a7c4ba6 100644 --- a/src/test/java/unicash/logic/commands/AddTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/AddTransactionCommandTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalTransactions.NUS; import java.nio.file.Path; import java.util.ArrayList; @@ -23,14 +24,12 @@ import unicash.model.UniCash; import unicash.model.transaction.Transaction; import unicash.testutil.TransactionBuilder; -import unicash.testutil.Assert; -import unicash.testutil.TypicalTransactions; public class AddTransactionCommandTest { @Test public void constructor_nullTransaction_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new AddTransactionCommand(null)); + assertThrows(NullPointerException.class, () -> new AddTransactionCommand(null)); } @Test @@ -83,8 +82,8 @@ public void equals() { @Test public void toStringMethod() { - AddTransactionCommand addTransactionCommand = new AddTransactionCommand(TypicalTransactions.NUS); - String expected = AddTransactionCommand.class.getCanonicalName() + "{toAdd=" + TypicalTransactions.NUS + "}"; + AddTransactionCommand addTransactionCommand = new AddTransactionCommand(NUS); + String expected = AddTransactionCommand.class.getCanonicalName() + "{toAdd=" + NUS + "}"; assertEquals(expected, addTransactionCommand.toString()); } diff --git a/src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java b/src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java index 13826f62ea9..d2f3a9e6ff8 100644 --- a/src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java +++ b/src/test/java/unicash/logic/commands/ClearTransactionsCommandTest.java @@ -1,6 +1,7 @@ package unicash.logic.commands; import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; +import static unicash.testutil.TypicalTransactions.getTypicalUniCash; import org.junit.jupiter.api.Test; @@ -8,7 +9,7 @@ import unicash.model.ModelManager; import unicash.model.UniCash; import unicash.model.UserPrefs; -import unicash.testutil.TypicalTransactions; + public class ClearTransactionsCommandTest { @@ -17,17 +18,17 @@ public void execute_emptyAddressBook_success() { Model model = new ModelManager(); Model expectedModel = new ModelManager(); - CommandTestUtil.assertCommandSuccess(new ClearTransactionsCommand(), model, + assertCommandSuccess(new ClearTransactionsCommand(), model, ClearTransactionsCommand.MESSAGE_SUCCESS, expectedModel); } @Test public void execute_nonEmptyUniCash_success() { - Model model = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + Model model = new ModelManager(getTypicalUniCash(), new UserPrefs()); Model expectedModel = new ModelManager(new UniCash(), new UserPrefs()); expectedModel.setUniCash(new UniCash()); - CommandTestUtil.assertCommandSuccess(new ClearTransactionsCommand(), model, + assertCommandSuccess(new ClearTransactionsCommand(), model, ClearTransactionsCommand.MESSAGE_SUCCESS, expectedModel); } diff --git a/src/test/java/unicash/logic/commands/CommandTestUtil.java b/src/test/java/unicash/logic/commands/CommandTestUtil.java index 9dc113f5917..03375bac660 100644 --- a/src/test/java/unicash/logic/commands/CommandTestUtil.java +++ b/src/test/java/unicash/logic/commands/CommandTestUtil.java @@ -2,6 +2,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_NAME; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; import static unicash.testutil.Assert.assertThrows; import java.util.ArrayList; @@ -15,8 +21,6 @@ import unicash.model.transaction.Transaction; import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; import unicash.testutil.EditTransactionDescriptorBuilder; -import unicash.logic.parser.CliSyntax; -import unicash.testutil.Assert; /** * Contains helper methods for testing commands. @@ -40,25 +44,25 @@ public class CommandTestUtil { public static final String VALID_LOCATION_ORCHARD = "orchard"; public static final String VALID_LOCATION_NUS = "NUS"; - public static final String TRANSACTION_NAME_DESC_NUS = " " + CliSyntax.PREFIX_NAME + VALID_TRANSACTION_NAME_NUS; - public static final String TRANSACTION_NAME_DESC_INTERN = " " + CliSyntax.PREFIX_NAME + VALID_TRANSACTION_NAME_INTERN; - public static final String AMOUNT_DESC_NUS = " " + CliSyntax.PREFIX_AMOUNT + VALID_AMOUNT_NUS; - public static final String AMOUNT_DESC_INTERN = " " + CliSyntax.PREFIX_AMOUNT + VALID_AMOUNT_INTERN; - public static final String DATETIME_DESC_NUS = " " + CliSyntax.PREFIX_DATETIME + VALID_DATETIME_NUS; - public static final String DATETIME_DESC_INTERN = " " + CliSyntax.PREFIX_DATETIME + VALID_DATETIME_INTERN; - public static final String TYPE_DESC_EXPENSE = " " + CliSyntax.PREFIX_TYPE + VALID_TYPE_EXPENSE; - public static final String TYPE_DESC_INCOME = " " + CliSyntax.PREFIX_TYPE + VALID_TYPE_INCOME; - public static final String CATEGORY_DESC_ENTERTAINMENT = " " + CliSyntax.PREFIX_CATEGORY + VALID_CATEGORY_ENTERTAINMENT; - public static final String CATEGORY_DESC_NUS = " " + CliSyntax.PREFIX_CATEGORY + VALID_CATEGORY_NUS; - public static final String LOCATION_DESC_ORCHARD = " " + CliSyntax.PREFIX_LOCATION + VALID_LOCATION_ORCHARD; - public static final String LOCATION_DESC_NUS = " " + CliSyntax.PREFIX_LOCATION + VALID_LOCATION_NUS; - - public static final String INVALID_TRANSACTION_NAME_DESC = " " + CliSyntax.PREFIX_NAME + "NUS&"; // '&' not allowed in names - public static final String INVALID_AMOUNT_DESC = " " + CliSyntax.PREFIX_AMOUNT + "-3.0"; // negative amounts not allowed - public static final String INVALID_DATETIME_DESC = " " + CliSyntax.PREFIX_DATETIME + "19/13/2001 19:30"; // invalid date - public static final String INVALID_TYPE_DESC = " " + CliSyntax.PREFIX_TYPE + "afaf"; // invalid type - public static final String INVALID_CATEGORY_DESC = " " + CliSyntax.PREFIX_CATEGORY + "afraf*&"; // invalid type - public static final String INVALID_LOCATION_DESC = " " + CliSyntax.PREFIX_LOCATION + "a214faf*&"; // invalid type + public static final String TRANSACTION_NAME_DESC_NUS = " " + PREFIX_NAME + VALID_TRANSACTION_NAME_NUS; + public static final String TRANSACTION_NAME_DESC_INTERN = " " + PREFIX_NAME + VALID_TRANSACTION_NAME_INTERN; + public static final String AMOUNT_DESC_NUS = " " + PREFIX_AMOUNT + VALID_AMOUNT_NUS; + public static final String AMOUNT_DESC_INTERN = " " + PREFIX_AMOUNT + VALID_AMOUNT_INTERN; + public static final String DATETIME_DESC_NUS = " " + PREFIX_DATETIME + VALID_DATETIME_NUS; + public static final String DATETIME_DESC_INTERN = " " + PREFIX_DATETIME + VALID_DATETIME_INTERN; + public static final String TYPE_DESC_EXPENSE = " " + PREFIX_TYPE + VALID_TYPE_EXPENSE; + public static final String TYPE_DESC_INCOME = " " + PREFIX_TYPE + VALID_TYPE_INCOME; + public static final String CATEGORY_DESC_ENTERTAINMENT = " " + PREFIX_CATEGORY + VALID_CATEGORY_ENTERTAINMENT; + public static final String CATEGORY_DESC_NUS = " " + PREFIX_CATEGORY + VALID_CATEGORY_NUS; + public static final String LOCATION_DESC_ORCHARD = " " + PREFIX_LOCATION + VALID_LOCATION_ORCHARD; + public static final String LOCATION_DESC_NUS = " " + PREFIX_LOCATION + VALID_LOCATION_NUS; + + public static final String INVALID_TRANSACTION_NAME_DESC = " " + PREFIX_NAME + "NUS&"; // '&' not allowed in names + public static final String INVALID_AMOUNT_DESC = " " + PREFIX_AMOUNT + "-3.0"; // negative amounts not allowed + public static final String INVALID_DATETIME_DESC = " " + PREFIX_DATETIME + "19/13/2001 19:30"; // invalid date + public static final String INVALID_TYPE_DESC = " " + PREFIX_TYPE + "afaf"; // invalid type + public static final String INVALID_CATEGORY_DESC = " " + PREFIX_CATEGORY + "afraf*&"; // invalid type + public static final String INVALID_LOCATION_DESC = " " + PREFIX_LOCATION + "a214faf*&"; // invalid type public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble"; @@ -127,7 +131,7 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri UniCash expectedUniCash = new UniCash(actualModel.getUniCash()); List expectedFilteredList = new ArrayList<>(actualModel.getFilteredTransactionList()); - Assert.assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); + assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedUniCash, actualModel.getUniCash()); assertEquals(expectedFilteredList, actualModel.getFilteredTransactionList()); } diff --git a/src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java b/src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java index 2d7f88dbfe1..ee62ea9611a 100644 --- a/src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/DeleteTransactionCommandTest.java @@ -4,7 +4,12 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static unicash.logic.commands.CommandTestUtil.assertCommandFailure; import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; +import static unicash.logic.commands.CommandTestUtil.showTransactionAtIndex; +import static unicash.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; +import static unicash.testutil.TypicalIndexes.INDEX_SECOND_TRANSACTION; +import static unicash.testutil.TypicalTransactions.getTypicalUniCash; import org.junit.jupiter.api.Test; @@ -14,8 +19,6 @@ import unicash.model.ModelManager; import unicash.model.UserPrefs; import unicash.model.transaction.Transaction; -import unicash.testutil.TypicalIndexes; -import unicash.testutil.TypicalTransactions; /** * Contains integration tests (interaction with the Model) and unit tests for @@ -23,27 +26,27 @@ */ public class DeleteTransactionCommandTest { - private final Model model = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalUniCash(), new UserPrefs()); @Test public void execute_invalidIndexUnfilteredList_throwsCommandException() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredTransactionList().size() + 1); DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(outOfBoundIndex); - CommandTestUtil.assertCommandFailure(deleteCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); + assertCommandFailure(deleteCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } @Test public void equals() { - DeleteTransactionCommand deleteFirstCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); - DeleteTransactionCommand deleteSecondCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_SECOND_TRANSACTION); + DeleteTransactionCommand deleteFirstCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); + DeleteTransactionCommand deleteSecondCommand = new DeleteTransactionCommand(INDEX_SECOND_TRANSACTION); // same object -> returns true assertEquals(deleteFirstCommand, deleteFirstCommand); // same values -> returns true DeleteTransactionCommand deleteFirstCommandCopy = - new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); + new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); assertEquals(deleteFirstCommand, deleteFirstCommandCopy); // different types -> returns false @@ -70,47 +73,47 @@ public void toStringMethod() { @Test public void execute_validIndexUnfilteredList_success() { Transaction transactionToDelete = model.getFilteredTransactionList().get( - TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); - DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); + INDEX_FIRST_TRANSACTION.getZeroBased()); + DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); String expectedMessage = String.format(DeleteTransactionCommand.MESSAGE_DELETE_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(transactionToDelete)); - ModelManager expectedModel = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + ModelManager expectedModel = new ModelManager(getTypicalUniCash(), new UserPrefs()); expectedModel.deleteTransaction(transactionToDelete); - CommandTestUtil.assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_validIndexFilteredList_success() { - CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); + showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); Transaction transactionToDelete = model.getFilteredTransactionList() - .get(TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); - DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION); + .get(INDEX_FIRST_TRANSACTION.getZeroBased()); + DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION); String expectedMessage = String.format(DeleteTransactionCommand.MESSAGE_DELETE_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(transactionToDelete)); - Model expectedModel = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + Model expectedModel = new ModelManager(getTypicalUniCash(), new UserPrefs()); expectedModel.deleteTransaction(transactionToDelete); showNoTransaction(expectedModel); - CommandTestUtil.assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); + showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); - Index outOfBoundIndex = TypicalIndexes.INDEX_SECOND_TRANSACTION; + Index outOfBoundIndex = INDEX_SECOND_TRANSACTION; // ensures that outOfBoundIndex is still in bounds of transactions list - assertTrue(outOfBoundIndex.getZeroBased() < TypicalTransactions.getTypicalUniCash().getTransactionList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < getTypicalUniCash().getTransactionList().size()); DeleteTransactionCommand deleteCommand = new DeleteTransactionCommand(outOfBoundIndex); - CommandTestUtil.assertCommandFailure(deleteCommand, model, + assertCommandFailure(deleteCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } diff --git a/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java b/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java index 4fdbf926033..a187d3f38eb 100644 --- a/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java @@ -4,43 +4,52 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static unicash.logic.commands.CommandTestUtil.DESC_NUS; +import static unicash.logic.commands.CommandTestUtil.DESC_SHOPPING; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_DATETIME_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; +import static unicash.logic.commands.CommandTestUtil.assertCommandFailure; import static unicash.logic.commands.CommandTestUtil.assertCommandSuccess; +import static unicash.logic.commands.CommandTestUtil.showTransactionAtIndex; +import static unicash.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; +import static unicash.testutil.TypicalIndexes.INDEX_SECOND_TRANSACTION; +import static unicash.testutil.TypicalTransactions.getTypicalUniCash; import org.junit.jupiter.api.Test; import unicash.commons.core.index.Index; import unicash.logic.UniCashMessages; +import unicash.logic.commands.EditTransactionCommand.EditTransactionDescriptor; import unicash.model.Model; import unicash.model.ModelManager; import unicash.model.UserPrefs; import unicash.model.transaction.Transaction; import unicash.testutil.EditTransactionDescriptorBuilder; import unicash.testutil.TransactionBuilder; -import unicash.testutil.TypicalIndexes; -import unicash.testutil.TypicalTransactions; /** * Contains integration tests (interaction with the Model) and unit tests for EditTransactionCommand. */ public class EditTransactionCommandTest { - private final Model model = new ModelManager(TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalUniCash(), new UserPrefs()); @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { Transaction editedTransaction = new TransactionBuilder().build(); - EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder( + EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder( editedTransaction).build(); - EditTransactionCommand editTransactionCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, descriptor); + EditTransactionCommand editTransactionCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, descriptor); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + getTypicalUniCash(), new UserPrefs()); expectedModel.setTransaction(model.getFilteredTransactionList().get(0), editedTransaction); - CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test @@ -50,70 +59,70 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { TransactionBuilder transactionInList = new TransactionBuilder(lastTransaction); Transaction editedTransaction = transactionInList - .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS) - .withAmount(CommandTestUtil.VALID_AMOUNT_NUS) - .withDateTime(CommandTestUtil.VALID_DATETIME_NUS).build(); - - EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() - .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS) - .withAmount(CommandTestUtil.VALID_AMOUNT_NUS) - .withDateTime(CommandTestUtil.VALID_DATETIME_NUS).build(); + .withName(VALID_TRANSACTION_NAME_NUS) + .withAmount(VALID_AMOUNT_NUS) + .withDateTime(VALID_DATETIME_NUS).build(); + + EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() + .withName(VALID_TRANSACTION_NAME_NUS) + .withAmount(VALID_AMOUNT_NUS) + .withDateTime(VALID_DATETIME_NUS).build(); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(indexLastTransaction, descriptor); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + getTypicalUniCash(), new UserPrefs()); expectedModel.setTransaction(lastTransaction, editedTransaction); - CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test public void execute_noFieldSpecifiedUnfilteredList_success() { - EditTransactionCommand editTransactionCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, - new EditTransactionCommand.EditTransactionDescriptor()); - Transaction editedTransaction = model.getFilteredTransactionList().get(TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); + EditTransactionCommand editTransactionCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, + new EditTransactionDescriptor()); + Transaction editedTransaction = model.getFilteredTransactionList().get(INDEX_FIRST_TRANSACTION.getZeroBased()); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + getTypicalUniCash(), new UserPrefs()); - CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test public void execute_filteredList_success() { - CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); + showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); Transaction transactionInFilteredList = model.getFilteredTransactionList() - .get(TypicalIndexes.INDEX_FIRST_TRANSACTION.getZeroBased()); + .get(INDEX_FIRST_TRANSACTION.getZeroBased()); Transaction editedTransaction = new TransactionBuilder(transactionInFilteredList) - .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build(); - EditTransactionCommand editTransactionCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, - new EditTransactionDescriptorBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build()); + .withName(VALID_TRANSACTION_NAME_NUS).build(); + EditTransactionCommand editTransactionCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, + new EditTransactionDescriptorBuilder().withName(VALID_TRANSACTION_NAME_NUS).build()); String expectedMessage = String.format(EditTransactionCommand.MESSAGE_EDIT_TRANSACTION_SUCCESS, UniCashMessages.formatTransaction(editedTransaction)); Model expectedModel = new ModelManager( - TypicalTransactions.getTypicalUniCash(), new UserPrefs()); + getTypicalUniCash(), new UserPrefs()); expectedModel.setTransaction(model.getFilteredTransactionList().get(0), editedTransaction); - CommandTestUtil.assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(editTransactionCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidTransactionIndexUnfilteredList_failure() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredTransactionList().size() + 1); - EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() - .withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build(); + EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder() + .withName(VALID_TRANSACTION_NAME_NUS).build(); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(outOfBoundIndex, descriptor); - CommandTestUtil.assertCommandFailure(editTransactionCommand, model, + assertCommandFailure(editTransactionCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } @@ -123,25 +132,25 @@ public void execute_invalidTransactionIndexUnfilteredList_failure() { */ @Test public void execute_invalidTransactionIndexFilteredList_failure() { - CommandTestUtil.showTransactionAtIndex(model, TypicalIndexes.INDEX_FIRST_TRANSACTION); - Index outOfBoundIndex = TypicalIndexes.INDEX_SECOND_TRANSACTION; + showTransactionAtIndex(model, INDEX_FIRST_TRANSACTION); + Index outOfBoundIndex = INDEX_SECOND_TRANSACTION; // ensures that outOfBoundIndex is still in bounds of address book list assertTrue(outOfBoundIndex.getZeroBased() < model.getUniCash().getTransactionList().size()); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(outOfBoundIndex, - new EditTransactionDescriptorBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS).build()); + new EditTransactionDescriptorBuilder().withName(VALID_TRANSACTION_NAME_NUS).build()); - CommandTestUtil.assertCommandFailure(editTransactionCommand, model, + assertCommandFailure(editTransactionCommand, model, UniCashMessages.MESSAGE_INVALID_TRANSACTION_DISPLAYED_INDEX); } @Test public void equals() { - final EditTransactionCommand standardCommand = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, CommandTestUtil.DESC_NUS); + final EditTransactionCommand standardCommand = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, DESC_NUS); // same values -> returns true - EditTransactionCommand.EditTransactionDescriptor copyDescriptor = new EditTransactionCommand.EditTransactionDescriptor(CommandTestUtil.DESC_NUS); - EditTransactionCommand commandWithSameValues = new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, + EditTransactionDescriptor copyDescriptor = new EditTransactionDescriptor(DESC_NUS); + EditTransactionCommand commandWithSameValues = new EditTransactionCommand(INDEX_FIRST_TRANSACTION, copyDescriptor); assertEquals(standardCommand, commandWithSameValues); @@ -159,20 +168,20 @@ public void equals() { assertFalse(standardCommand.equals(copyDescriptor)); // different index -> returns false - assertNotEquals(standardCommand, new EditTransactionCommand(TypicalIndexes.INDEX_SECOND_TRANSACTION, CommandTestUtil.DESC_NUS)); + assertNotEquals(standardCommand, new EditTransactionCommand(INDEX_SECOND_TRANSACTION, DESC_NUS)); // different descriptor -> returns false - assertNotEquals(standardCommand, new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, CommandTestUtil.DESC_SHOPPING)); + assertNotEquals(standardCommand, new EditTransactionCommand(INDEX_FIRST_TRANSACTION, DESC_SHOPPING)); } @Test public void toStringMethod() { Index index = Index.fromOneBased(1); - EditTransactionCommand.EditTransactionDescriptor editTransactionDescriptor = new EditTransactionCommand.EditTransactionDescriptor(); + EditTransactionDescriptor editTransactionDescriptor = new EditTransactionDescriptor(); EditTransactionCommand editTransactionCommand = new EditTransactionCommand(index, editTransactionDescriptor); String expected = EditTransactionCommand.class.getCanonicalName() + "{index=" + index + ", editTransactionDescriptor=" + editTransactionDescriptor + "}"; - assertEquals(expected, editTransactionCommand.toString()); + assertEquals(expected, toString()); } } diff --git a/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java b/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java index 0915eb5948e..50b13a359e4 100644 --- a/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java +++ b/src/test/java/unicash/logic/commands/ExitCommandUniCashTest.java @@ -17,7 +17,7 @@ public void execute_exit_success() { CommandResult expectedCommandResult = new CommandResult(ExitCommandUniCash.MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true); - CommandTestUtil.assertCommandSuccess(new ExitCommandUniCash(), model, + assertCommandSuccess(new ExitCommandUniCash(), model, expectedCommandResult, expectedModel); } } diff --git a/src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java b/src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java index 5d1ffeb97c1..96a4784b41e 100644 --- a/src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java +++ b/src/test/java/unicash/logic/commands/GetTotalExpenditureCommandTest.java @@ -5,7 +5,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static unicash.testutil.Assert.assertThrows; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import unicash.commons.enums.TransactionType; @@ -16,7 +15,6 @@ import unicash.model.UserPrefs; import unicash.model.category.Category; import unicash.testutil.TransactionBuilder; -import unicash.testutil.Assert; public class GetTotalExpenditureCommandTest { @@ -25,19 +23,19 @@ public class GetTotalExpenditureCommandTest { @Test public void execute_nullModel_throwsNullPointerException() { var command = new GetTotalExpenditureCommand(10, null); - Assert.assertThrows(NullPointerException.class, () -> command.execute(null)); + assertThrows(NullPointerException.class, () -> command.execute(null)); } @Test public void execute_negativeMonth_throwsCommandException() { var command = new GetTotalExpenditureCommand(-12, null); - Assert.assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); + assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); } @Test public void execute_monthGreaterThan12_throwsCommandException() { var command = new GetTotalExpenditureCommand(13, null); - Assert.assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); + assertThrows(CommandException.class, () -> command.execute(BASE_MODEL)); } @Test @@ -67,7 +65,7 @@ public void execute_multipleMonthsOnly_filtersOnlySelectedMonths() throws Comman assertEquals(2, filteredResult.size()); for (var result : filteredResult) { assertEquals(TransactionType.EXPENSE, result.getType().type); - Assertions.assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); + assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); } } @@ -83,7 +81,7 @@ public void execute_multipleCategoriesOnly_filtersOnlySelectedCategory() throws assertEquals(2, filteredResult.size()); for (var result : filteredResult) { assertEquals(TransactionType.EXPENSE, result.getType().type); - Assertions.assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); + assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); } } @@ -99,8 +97,8 @@ public void execute_multipleMonthsAndCategories_filtersForSelectedMonthAndCatego assertEquals(1, filteredResult.size()); for (var result : filteredResult) { assertEquals(TransactionType.EXPENSE, result.getType().type); - Assertions.assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); - Assertions.assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); + assertTrue(result.getCategories().stream().anyMatch(cat -> cat.equals(new Category("Food")))); + assertEquals(8, result.getDateTime().getDateTime().getMonthValue()); } } diff --git a/src/test/java/unicash/logic/commands/ListCommandTest.java b/src/test/java/unicash/logic/commands/ListCommandTest.java index 59a5374a73e..e874cda5860 100644 --- a/src/test/java/unicash/logic/commands/ListCommandTest.java +++ b/src/test/java/unicash/logic/commands/ListCommandTest.java @@ -26,6 +26,6 @@ public void setUp() { @Test public void execute_listIsNotFiltered_showsSameList() { - CommandTestUtil.assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); + assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); } } diff --git a/src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java b/src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java index 5aadf937351..27e4a556e84 100644 --- a/src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/AddTransactionCommandParserTest.java @@ -23,6 +23,12 @@ import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; import static unicash.logic.commands.CommandTestUtil.VALID_TYPE_EXPENSE; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_NAME; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; import static unicash.logic.parser.CommandParserTestUtil.assertParseFailure; import static unicash.logic.parser.CommandParserTestUtil.assertParseSuccess; import static unicash.testutil.TypicalTransactions.NUS; @@ -31,11 +37,10 @@ import unicash.logic.UniCashMessages; import unicash.logic.commands.AddTransactionCommand; -import unicash.model.transaction.*; -import unicash.model.transaction.Transaction; -import unicash.testutil.TransactionBuilder; import unicash.model.transaction.Amount; +import unicash.model.transaction.Transaction; import unicash.model.transaction.Type; +import unicash.testutil.TransactionBuilder; public class AddTransactionCommandParserTest { @@ -65,79 +70,79 @@ public void parse_repeatedValue_failure() { // multiple names assertParseFailure(parser, TRANSACTION_NAME_DESC_INTERN + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_NAME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // multiple amount assertParseFailure(parser, AMOUNT_DESC_INTERN + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_AMOUNT)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_AMOUNT)); // multiple datetime assertParseFailure(parser, DATETIME_DESC_INTERN + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_DATETIME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_DATETIME)); // multiple type assertParseFailure(parser, TYPE_DESC_INCOME + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_TYPE)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_TYPE)); // multiple location assertParseFailure(parser, LOCATION_DESC_ORCHARD + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); // multiple category assertParseFailure(parser, CATEGORY_DESC_ENTERTAINMENT + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_CATEGORY)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_CATEGORY)); // invalid value followed by valid value // invalid name assertParseFailure(parser, INVALID_TRANSACTION_NAME_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_NAME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // invalid amount assertParseFailure(parser, INVALID_AMOUNT_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_AMOUNT)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_AMOUNT)); // invalid datetime assertParseFailure(parser, INVALID_DATETIME_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_DATETIME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_DATETIME)); // invalid type assertParseFailure(parser, INVALID_TYPE_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_TYPE)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_TYPE)); // invalid category assertParseFailure(parser, INVALID_CATEGORY_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_CATEGORY)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_CATEGORY)); // invalid location assertParseFailure(parser, INVALID_LOCATION_DESC + validExpectedTransactionString, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); // valid value followed by invalid value // invalid name assertParseFailure(parser, validExpectedTransactionString + INVALID_TRANSACTION_NAME_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_NAME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // invalid amount assertParseFailure(parser, validExpectedTransactionString + INVALID_AMOUNT_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_AMOUNT)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_AMOUNT)); // invalid datetime assertParseFailure(parser, validExpectedTransactionString + INVALID_DATETIME_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_DATETIME)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_DATETIME)); // invalid type assertParseFailure(parser, validExpectedTransactionString + INVALID_TYPE_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_TYPE)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_TYPE)); // invalid category assertParseFailure(parser, validExpectedTransactionString + INVALID_CATEGORY_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_CATEGORY)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_CATEGORY)); // invalid location assertParseFailure(parser, validExpectedTransactionString + INVALID_LOCATION_DESC, - UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); + UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); } @Test @@ -161,7 +166,7 @@ public void parse_compulsoryFieldMissing_failure() { public void parse_invalidValue_failure() { // invalid name assertParseFailure(parser, INVALID_TRANSACTION_NAME_DESC + AMOUNT_DESC_NUS + DATETIME_DESC_NUS - + TYPE_DESC_EXPENSE, Name.MESSAGE_CONSTRAINTS); + + TYPE_DESC_EXPENSE, unicash.model.transaction.Name.MESSAGE_CONSTRAINTS); // invalid amount assertParseFailure(parser, TRANSACTION_NAME_DESC_NUS + INVALID_AMOUNT_DESC diff --git a/src/test/java/unicash/logic/parser/AddressBookParserTest.java b/src/test/java/unicash/logic/parser/AddressBookParserTest.java index b7da9c860b1..fbdd68fa8b7 100644 --- a/src/test/java/unicash/logic/parser/AddressBookParserTest.java +++ b/src/test/java/unicash/logic/parser/AddressBookParserTest.java @@ -5,6 +5,7 @@ import static unicash.logic.UniCashMessages.MESSAGE_INVALID_COMMAND_FORMAT; import static unicash.logic.UniCashMessages.MESSAGE_UNKNOWN_COMMAND; import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; import java.util.Arrays; import java.util.List; @@ -27,8 +28,6 @@ import unicash.testutil.EditTransactionDescriptorBuilder; import unicash.testutil.TransactionBuilder; import unicash.testutil.TransactionUtil; -import unicash.testutil.Assert; -import unicash.testutil.TypicalIndexes; public class AddressBookParserTest { @@ -72,8 +71,8 @@ public void parseCommand_deleteTransaction() throws Exception { DeleteTransactionCommand command = (DeleteTransactionCommand) parser.parseCommand( DeleteTransactionCommand.COMMAND_WORD + " " - + TypicalIndexes.INDEX_FIRST_TRANSACTION.getOneBased()); - assertEquals(new DeleteTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION), command); + + INDEX_FIRST_TRANSACTION.getOneBased()); + assertEquals(new DeleteTransactionCommand(INDEX_FIRST_TRANSACTION), command); } @Test @@ -88,10 +87,10 @@ public void parseCommand_editTransaction() throws Exception { Transaction transaction = new TransactionBuilder().build(); EditTransactionCommand.EditTransactionDescriptor descriptor = new EditTransactionDescriptorBuilder(transaction) .build(); - String input = EditTransactionCommand.COMMAND_WORD + " " + TypicalIndexes.INDEX_FIRST_TRANSACTION.getOneBased() + " "; + String input = EditTransactionCommand.COMMAND_WORD + " " + INDEX_FIRST_TRANSACTION.getOneBased() + " "; input += TransactionUtil.getEditTransactionDescriptorDetails(descriptor); EditTransactionCommand command = (EditTransactionCommand) parser.parseCommand(input); - assertEquals(new EditTransactionCommand(TypicalIndexes.INDEX_FIRST_TRANSACTION, descriptor), command); + assertEquals(new EditTransactionCommand(INDEX_FIRST_TRANSACTION, descriptor), command); } @Test @@ -125,11 +124,11 @@ public void parseCommand_exitUniCash() throws Exception { @Test public void parseCommand_unrecognisedInput_throwsParseException() { var message = String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommandUniCash.MESSAGE_USAGE); - Assert.assertThrows(ParseException.class, message, () -> parser.parseCommand("")); + assertThrows(ParseException.class, message, () -> parser.parseCommand("")); } @Test public void parseCommand_unknownCommand_throwsParseException() { - Assert.assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, () -> parser.parseCommand("unknownCommand")); + assertThrows(ParseException.class, MESSAGE_UNKNOWN_COMMAND, () -> parser.parseCommand("unknownCommand")); } } diff --git a/src/test/java/unicash/logic/parser/CommandParserTestUtil.java b/src/test/java/unicash/logic/parser/CommandParserTestUtil.java index b60047ef5ae..6300d5604d5 100644 --- a/src/test/java/unicash/logic/parser/CommandParserTestUtil.java +++ b/src/test/java/unicash/logic/parser/CommandParserTestUtil.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.jupiter.api.Assertions; import unicash.logic.commands.Command; import unicash.logic.parser.exceptions.ParseException; @@ -34,7 +33,7 @@ public static void assertParseFailure(Parser parser, String u parser.parse(userInput); throw new AssertionError("The expected ParseException was not thrown."); } catch (ParseException | IllegalArgumentException e) { - Assertions.assertEquals(expectedMessage, e.getMessage()); + assertEquals(expectedMessage, e.getMessage()); } } } diff --git a/src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java b/src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java index 8cf2a02900b..ce71d20824a 100644 --- a/src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java +++ b/src/test/java/unicash/logic/parser/EditTransactionCommandParserTest.java @@ -26,6 +26,11 @@ import static unicash.logic.commands.CommandTestUtil.VALID_LOCATION_NUS; import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; import static unicash.logic.commands.CommandTestUtil.VALID_TYPE_INCOME; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; import static unicash.logic.parser.CommandParserTestUtil.assertParseFailure; import static unicash.logic.parser.CommandParserTestUtil.assertParseSuccess; import static unicash.testutil.TypicalIndexes.INDEX_FIRST_TRANSACTION; @@ -45,11 +50,12 @@ import unicash.model.transaction.Type; import unicash.testutil.EditTransactionDescriptorBuilder; + public class EditTransactionCommandParserTest { private static final String MESSAGE_INVALID_FORMAT = String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditTransactionCommand.MESSAGE_USAGE); - private static final String CATEGORY_EMPTY = " " + CliSyntax.PREFIX_CATEGORY; + private static final String CATEGORY_EMPTY = " " + PREFIX_CATEGORY; private final EditTransactionCommandParser parser = new EditTransactionCommandParser(); @@ -227,12 +233,12 @@ public void parse_multipleRepeatedFields_failure() { Index targetIndex = INDEX_FIRST_TRANSACTION; String userInput = targetIndex.getOneBased() + LOCATION_DESC_NUS + INVALID_LOCATION_DESC; - assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); + assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); // invalid followed by valid userInput = targetIndex.getOneBased() + INVALID_LOCATION_DESC + LOCATION_DESC_NUS; - assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(CliSyntax.PREFIX_LOCATION)); + assertParseFailure(parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes(PREFIX_LOCATION)); // multiple valid fields repeated userInput = targetIndex.getOneBased() @@ -256,11 +262,11 @@ public void parse_multipleRepeatedFields_failure() { parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes( - CliSyntax.PREFIX_LOCATION, - CliSyntax.PREFIX_TYPE, - CliSyntax.PREFIX_AMOUNT, - CliSyntax.PREFIX_DATETIME, - CliSyntax.PREFIX_CATEGORY + PREFIX_LOCATION, + PREFIX_TYPE, + PREFIX_AMOUNT, + PREFIX_DATETIME, + PREFIX_CATEGORY ) ); @@ -277,9 +283,9 @@ public void parse_multipleRepeatedFields_failure() { parser, userInput, UniCashMessages.getErrorMessageForDuplicatePrefixes( - CliSyntax.PREFIX_LOCATION, - CliSyntax.PREFIX_CATEGORY, - CliSyntax.PREFIX_DATETIME + PREFIX_LOCATION, + PREFIX_CATEGORY, + PREFIX_DATETIME ) ); } diff --git a/src/test/java/unicash/logic/parser/ParserUtilTest.java b/src/test/java/unicash/logic/parser/ParserUtilTest.java index 74f513eef8f..0cf6ac65672 100644 --- a/src/test/java/unicash/logic/parser/ParserUtilTest.java +++ b/src/test/java/unicash/logic/parser/ParserUtilTest.java @@ -3,14 +3,15 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static unicash.logic.parser.ParserUtil.MESSAGE_INVALID_INDEX; import static unicash.testutil.Assert.assertThrows; +import static unicash.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import unicash.logic.parser.exceptions.ParseException; @@ -19,8 +20,6 @@ import unicash.model.transaction.DateTime; import unicash.model.transaction.Location; import unicash.model.transaction.Name; -import unicash.testutil.Assert; -import unicash.testutil.TypicalIndexes; // TODO: Need more testing here public class ParserUtilTest { @@ -40,91 +39,91 @@ public class ParserUtilTest { @Test public void parseIndex_invalidInput_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseIndex("10 a")); + assertThrows(ParseException.class, () -> ParserUtil.parseIndex("10 a")); } @Test public void parseIndex_outOfRangeInput_throwsParseException() { - Assert.assertThrows(ParseException.class, ParserUtil.MESSAGE_INVALID_INDEX, () + assertThrows(ParseException.class, MESSAGE_INVALID_INDEX, () -> ParserUtil.parseIndex(Long.toString(Integer.MAX_VALUE + 1))); } @Test public void parseIndex_validInput_success() throws Exception { // No whitespaces - Assertions.assertEquals(TypicalIndexes.INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); + assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); // Leading and trailing whitespaces - Assertions.assertEquals(TypicalIndexes.INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); + assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); } @Test public void parseTransactionName_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseTransactionName(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseTransactionName(null)); } @Test public void parseTransactionName_invalidValue_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseTransactionName(INVALID_NAME)); + assertThrows(ParseException.class, () -> ParserUtil.parseTransactionName(INVALID_NAME)); } @Test public void parseTransactionName_validValueWithoutWhitespace_returnsTransactionName() throws Exception { Name expectedTransactionName = new Name(VALID_NAME); - Assertions.assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(VALID_NAME)); + assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(VALID_NAME)); } @Test public void parseTransactionName_validValueWithWhitespace_returnsTrimmedTransactionName() throws Exception { String nameWithWhitespace = WHITESPACE + VALID_NAME + WHITESPACE; Name expectedTransactionName = new Name(VALID_NAME); - Assertions.assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(nameWithWhitespace)); + assertEquals(expectedTransactionName, ParserUtil.parseTransactionName(nameWithWhitespace)); } @Test public void parseAmount_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseAmount(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseAmount(null)); } @Test public void parseAmount_invalidValue_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseAmount(INVALID_AMOUNT)); + assertThrows(ParseException.class, () -> ParserUtil.parseAmount(INVALID_AMOUNT)); } @Test public void parseAmount_validValueWithoutWhitespace_returnsTransactionName() throws Exception { Amount expectedAmount = new Amount(3.0); - Assertions.assertEquals(expectedAmount, ParserUtil.parseAmount(VALID_AMOUNT)); + assertEquals(expectedAmount, ParserUtil.parseAmount(VALID_AMOUNT)); } @Test public void parseAmount_validValueWithWhitespace_returnsTrimmedTransactionName() throws Exception { String amountWithWhitespace = WHITESPACE + VALID_AMOUNT + WHITESPACE; Amount expectedAmount = new Amount(3.0); - Assertions.assertEquals(expectedAmount, ParserUtil.parseAmount(amountWithWhitespace)); + assertEquals(expectedAmount, ParserUtil.parseAmount(amountWithWhitespace)); } @Test public void parseDateTime_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseDateTime(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseDateTime(null)); } @Test public void parseDateTime_invalidValue_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseDateTime(INVALID_DATETIME)); + assertThrows(ParseException.class, () -> ParserUtil.parseDateTime(INVALID_DATETIME)); } @Test public void parseDateTime_validValueWithoutWhitespace_returnsTransactionName() throws Exception { DateTime expectedDateTime = new DateTime(VALID_DATETIME); - Assertions.assertEquals(expectedDateTime, ParserUtil.parseDateTime(VALID_DATETIME)); + assertEquals(expectedDateTime, ParserUtil.parseDateTime(VALID_DATETIME)); } @Test public void parseDateTime_validValueWithWhitespace_returnsTrimmedTransactionName() throws Exception { String dateTimeWithWhiteSpace = WHITESPACE + VALID_DATETIME + WHITESPACE; DateTime expectedDateTime = new DateTime(VALID_DATETIME); - Assertions.assertEquals(expectedDateTime, ParserUtil.parseDateTime(dateTimeWithWhiteSpace)); + assertEquals(expectedDateTime, ParserUtil.parseDateTime(dateTimeWithWhiteSpace)); } @Test @@ -135,64 +134,64 @@ public void parseCategory_empty_doesNotThrow() throws Exception { @Test public void parseLocation_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseLocation(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseLocation(null)); } @Test public void parseLocation_invalidValue_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseLocation(INVALID_LOCATION)); + assertThrows(ParseException.class, () -> ParserUtil.parseLocation(INVALID_LOCATION)); } @Test public void parseLocation_validValueWithoutWhitespace_returnsTransactionName() throws Exception { Location expectedLocation = new Location(VALID_LOCATION); - Assertions.assertEquals(expectedLocation, ParserUtil.parseLocation(VALID_LOCATION)); + assertEquals(expectedLocation, ParserUtil.parseLocation(VALID_LOCATION)); } @Test public void parseLocation_validValueWithWhitespace_returnsTrimmedLocation() throws Exception { String locationWithWhiteSpace = WHITESPACE + VALID_LOCATION + WHITESPACE; Location expectedLocation = new Location(VALID_LOCATION); - Assertions.assertEquals(expectedLocation, ParserUtil.parseLocation(locationWithWhiteSpace)); + assertEquals(expectedLocation, ParserUtil.parseLocation(locationWithWhiteSpace)); } @Test public void parseLocation_empty_returnsDefaultLocation() throws Exception { Location expectedLocation = new Location(WHITESPACE); - Assertions.assertEquals(expectedLocation, ParserUtil.parseLocation(WHITESPACE)); + assertEquals(expectedLocation, ParserUtil.parseLocation(WHITESPACE)); } @Test public void parseCategory_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseCategory(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseCategory(null)); } @Test public void parseCategory_invalidValue_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseCategory(INVALID_CATEGORY)); + assertThrows(ParseException.class, () -> ParserUtil.parseCategory(INVALID_CATEGORY)); } @Test public void parseCategory_validValueWithoutWhitespace_returnsCategory() throws Exception { Category expectedCategory = new Category(VALID_CATEGORY); - Assertions.assertEquals(expectedCategory, ParserUtil.parseCategory(VALID_CATEGORY)); + assertEquals(expectedCategory, ParserUtil.parseCategory(VALID_CATEGORY)); } @Test public void parseCategory_validValueWithWhitespace_returnsTrimmedCategory() throws Exception { String categoryWithWhitespace = WHITESPACE + VALID_CATEGORY + WHITESPACE; Category expectedCategory = new Category(VALID_CATEGORY); - Assertions.assertEquals(expectedCategory, ParserUtil.parseCategory(categoryWithWhitespace)); + assertEquals(expectedCategory, ParserUtil.parseCategory(categoryWithWhitespace)); } @Test public void parseCategories_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> ParserUtil.parseCategories(null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseCategories(null)); } @Test public void parseCategories_collectionWithInvalidCategories_throwsParseException() { - Assert.assertThrows(ParseException.class, () -> ParserUtil.parseCategories( + assertThrows(ParseException.class, () -> ParserUtil.parseCategories( Arrays.asList(VALID_CATEGORY, INVALID_CATEGORY))); } diff --git a/src/test/java/unicash/model/ModelManagerTest.java b/src/test/java/unicash/model/ModelManagerTest.java index c0a5c39ab67..6e0258239fb 100644 --- a/src/test/java/unicash/model/ModelManagerTest.java +++ b/src/test/java/unicash/model/ModelManagerTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static unicash.model.Model.PREDICATE_SHOW_ALL_TRANSACTIONS; import static unicash.testutil.Assert.assertThrows; import static unicash.testutil.TypicalTransactions.BUYING_GROCERIES; import static unicash.testutil.TypicalTransactions.INTERN; @@ -14,14 +15,12 @@ import java.nio.file.Paths; import java.util.Arrays; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import unicash.commons.core.GuiSettings; import unicash.model.transaction.TransactionNameContainsKeywordsPredicate; import unicash.model.transaction.exceptions.TransactionNotFoundException; import unicash.testutil.UniCashBuilder; -import unicash.testutil.Assert; public class ModelManagerTest { @@ -30,13 +29,13 @@ public class ModelManagerTest { @Test public void constructor() { assertEquals(new UserPrefs(), modelManager.getUserPrefs()); - Assertions.assertEquals(new GuiSettings(), modelManager.getGuiSettings()); + assertEquals(new GuiSettings(), modelManager.getGuiSettings()); assertEquals(new UniCash(), new UniCash(modelManager.getUniCash())); } @Test public void setUserPrefs_nullUserPrefs_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> modelManager.setUserPrefs(null)); + assertThrows(NullPointerException.class, () -> modelManager.setUserPrefs(null)); } @Test @@ -55,19 +54,19 @@ public void setUserPrefs_validUserPrefs_copiesUserPrefs() { @Test public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> modelManager.setGuiSettings(null)); + assertThrows(NullPointerException.class, () -> modelManager.setGuiSettings(null)); } @Test public void setGuiSettings_validGuiSettings_setsGuiSettings() { GuiSettings guiSettings = new GuiSettings(1, 2, 3, 4); modelManager.setGuiSettings(guiSettings); - Assertions.assertEquals(guiSettings, modelManager.getGuiSettings()); + assertEquals(guiSettings, modelManager.getGuiSettings()); } @Test public void setUniCashFilePath_nullPath_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> modelManager.setUniCashFilePath(null)); + assertThrows(NullPointerException.class, () -> modelManager.setUniCashFilePath(null)); } @Test @@ -79,12 +78,12 @@ public void setUniCashFilePath_validPath_setsUniCashFilePath() { @Test public void setUniCash_nullTransaction_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> modelManager.setUniCash(null)); + assertThrows(NullPointerException.class, () -> modelManager.setUniCash(null)); } @Test public void hasTransaction_nullTransaction_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> modelManager.hasTransaction(null)); + assertThrows(NullPointerException.class, () -> modelManager.hasTransaction(null)); } @Test @@ -101,7 +100,7 @@ public void hasTransaction_transactionInUniCash_returnsTrue() { @Test public void deleteTransaction_transactionNotInUniCash_throws() { modelManager.addTransaction(NUS); - Assert.assertThrows(TransactionNotFoundException.class, () -> modelManager.deleteTransaction(BUYING_GROCERIES)); + assertThrows(TransactionNotFoundException.class, () -> modelManager.deleteTransaction(BUYING_GROCERIES)); } @Test @@ -112,7 +111,7 @@ public void deleteTransaction_transactionInUniCash_throws() { @Test public void getFilteredUniCash_modifyList_throwsUnsupportedOperationException() { - Assert.assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredTransactionList().remove(0)); + assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredTransactionList().remove(0)); } @Test @@ -146,7 +145,7 @@ public void equals() { assertFalse(modelManager.equals(new ModelManager(uniCash, userPrefs))); // resets modelManager to initial state for upcoming tests - modelManager.updateFilteredTransactionList(Model.PREDICATE_SHOW_ALL_TRANSACTIONS); + modelManager.updateFilteredTransactionList(PREDICATE_SHOW_ALL_TRANSACTIONS); // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); diff --git a/src/test/java/unicash/model/UserPrefsTest.java b/src/test/java/unicash/model/UserPrefsTest.java index 52165a2ef69..d836a0e4a79 100644 --- a/src/test/java/unicash/model/UserPrefsTest.java +++ b/src/test/java/unicash/model/UserPrefsTest.java @@ -10,20 +10,19 @@ import org.junit.jupiter.api.Test; import unicash.commons.core.GuiSettings; -import unicash.testutil.Assert; public class UserPrefsTest { @Test public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { UserPrefs userPref = new UserPrefs(); - Assert.assertThrows(NullPointerException.class, () -> userPref.setGuiSettings(null)); + assertThrows(NullPointerException.class, () -> userPref.setGuiSettings(null)); } @Test public void setUniCashFilePath_nullPath_throwsNullPointerException() { UserPrefs userPrefs = new UserPrefs(); - Assert.assertThrows(NullPointerException.class, () -> userPrefs.setUniCashFilePath(null)); + assertThrows(NullPointerException.class, () -> userPrefs.setUniCashFilePath(null)); } @Test diff --git a/src/test/java/unicash/model/transaction/AmountTest.java b/src/test/java/unicash/model/transaction/AmountTest.java index 67e9f9d5e0c..571582b1df4 100644 --- a/src/test/java/unicash/model/transaction/AmountTest.java +++ b/src/test/java/unicash/model/transaction/AmountTest.java @@ -7,12 +7,11 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; public class AmountTest { @Test public void constructor_negativeAmount_throwsIllegalArgumentException() { - Assert.assertThrows(IllegalArgumentException.class, () -> new Amount(-10)); + assertThrows(IllegalArgumentException.class, () -> new Amount(-10)); } @Test diff --git a/src/test/java/unicash/model/transaction/DateTimeTest.java b/src/test/java/unicash/model/transaction/DateTimeTest.java index 5ffadad35cd..e674ea09d34 100644 --- a/src/test/java/unicash/model/transaction/DateTimeTest.java +++ b/src/test/java/unicash/model/transaction/DateTimeTest.java @@ -10,15 +10,14 @@ import java.time.ZoneId; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; public class DateTimeTest { @Test public void constructor_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new DateTime(null)); - Assert.assertThrows(NullPointerException.class, () -> new DateTime("18-08-2001 18:18", null)); - Assert.assertThrows(NullPointerException.class, () -> new DateTime(null, null)); + assertThrows(NullPointerException.class, () -> new DateTime(null)); + assertThrows(NullPointerException.class, () -> new DateTime("18-08-2001 18:18", null)); + assertThrows(NullPointerException.class, () -> new DateTime(null, null)); } @Test From e34e80ee44d1e0a15a943b0ecfaaf81a48013863 Mon Sep 17 00:00:00 2001 From: Rubesh S Date: Wed, 18 Oct 2023 16:34:44 +0800 Subject: [PATCH 5/5] Fix style yet again --- .../commands/EditTransactionCommandTest.java | 2 +- .../model/transaction/LocationTest.java | 5 +- .../unicash/model/transaction/NameTest.java | 8 +-- .../model/transaction/TransactionTest.java | 61 ++++++++++--------- .../unicash/model/transaction/TypeTest.java | 5 +- .../storage/JsonAdaptedTransactionTest.java | 26 ++++---- .../storage/JsonUserPrefsStorageTest.java | 10 +-- .../unicash/testutil/TransactionUtil.java | 38 +++++++----- .../unicash/testutil/TypicalTransactions.java | 52 ++++++++++------ src/test/java/unicash/ui/UiPartTest.java | 25 ++++---- 10 files changed, 127 insertions(+), 105 deletions(-) diff --git a/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java b/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java index a187d3f38eb..8a301514f50 100644 --- a/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java +++ b/src/test/java/unicash/logic/commands/EditTransactionCommandTest.java @@ -181,7 +181,7 @@ public void toStringMethod() { EditTransactionCommand editTransactionCommand = new EditTransactionCommand(index, editTransactionDescriptor); String expected = EditTransactionCommand.class.getCanonicalName() + "{index=" + index + ", editTransactionDescriptor=" + editTransactionDescriptor + "}"; - assertEquals(expected, toString()); + assertEquals(expected, editTransactionCommand.toString()); } } diff --git a/src/test/java/unicash/model/transaction/LocationTest.java b/src/test/java/unicash/model/transaction/LocationTest.java index 922f99dc3a3..8f3063d9167 100644 --- a/src/test/java/unicash/model/transaction/LocationTest.java +++ b/src/test/java/unicash/model/transaction/LocationTest.java @@ -7,13 +7,12 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; public class LocationTest { @Test public void constructor_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new Location(null)); + assertThrows(NullPointerException.class, () -> new Location(null)); } @Test @@ -25,7 +24,7 @@ public void constructor_noLocation_setDefault() { @Test public void isValidLocation() { // null name - Assert.assertThrows(NullPointerException.class, () -> Location.isValidLocation(null)); + assertThrows(NullPointerException.class, () -> Location.isValidLocation(null)); // invalid name assertFalse(Location.isValidLocation("")); // empty string diff --git a/src/test/java/unicash/model/transaction/NameTest.java b/src/test/java/unicash/model/transaction/NameTest.java index 2a4eee93603..9ab9946eadf 100644 --- a/src/test/java/unicash/model/transaction/NameTest.java +++ b/src/test/java/unicash/model/transaction/NameTest.java @@ -7,25 +7,25 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; + public class NameTest { @Test public void constructor_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new Name(null)); + assertThrows(NullPointerException.class, () -> new Name(null)); } @Test public void constructor_invalidName_throwsIllegalArgumentException() { String invalidName = ""; - Assert.assertThrows(IllegalArgumentException.class, () -> new Name(invalidName)); + assertThrows(IllegalArgumentException.class, () -> new Name(invalidName)); } @Test public void isValidName() { // null name - Assert.assertThrows(NullPointerException.class, () -> Name.isValidName(null)); + assertThrows(NullPointerException.class, () -> Name.isValidName(null)); // invalid name assertFalse(Name.isValidName("")); // empty string diff --git a/src/test/java/unicash/model/transaction/TransactionTest.java b/src/test/java/unicash/model/transaction/TransactionTest.java index fc25b712cfc..dbd4b6946e7 100644 --- a/src/test/java/unicash/model/transaction/TransactionTest.java +++ b/src/test/java/unicash/model/transaction/TransactionTest.java @@ -3,82 +3,83 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static unicash.testutil.TypicalTransactions.BUYING_GROCERIES; +import static unicash.testutil.TypicalTransactions.DINING_WITH_FRIENDS; +import static unicash.testutil.TypicalTransactions.WORK_AT_LIHO; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import unicash.testutil.TransactionBuilder; -import unicash.testutil.TypicalTransactions; public class TransactionTest { @Test public void equals() { // same values -> returns true - Transaction groceriesCopy = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).build(); - Assertions.assertEquals(TypicalTransactions.BUYING_GROCERIES, groceriesCopy); + Transaction groceriesCopy = new TransactionBuilder(BUYING_GROCERIES).build(); + assertEquals(BUYING_GROCERIES, groceriesCopy); // same object -> returns true - Assertions.assertEquals(TypicalTransactions.BUYING_GROCERIES, TypicalTransactions.BUYING_GROCERIES); + assertEquals(BUYING_GROCERIES, BUYING_GROCERIES); // null -> returns false assertNotEquals(null, groceriesCopy); // null -> returns false - Assertions.assertNotEquals(null, TypicalTransactions.BUYING_GROCERIES); + assertNotEquals(null, BUYING_GROCERIES); // different type -> returns false - Assertions.assertNotEquals(5, TypicalTransactions.BUYING_GROCERIES); + assertNotEquals(5, BUYING_GROCERIES); - Assertions.assertFalse(TypicalTransactions.BUYING_GROCERIES.equals(5)); + assertFalse(BUYING_GROCERIES.equals(5)); // different person -> returns false - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, TypicalTransactions.DINING_WITH_FRIENDS); + assertNotEquals(BUYING_GROCERIES, DINING_WITH_FRIENDS); // different name -> returns false - Transaction editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withName("Another thing").build(); - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + Transaction editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withName("Another thing").build(); + assertNotEquals(BUYING_GROCERIES, editedGroceries); // different amount -> returns false - editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withAmount(10.15).build(); - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withAmount(10.15).build(); + assertNotEquals(BUYING_GROCERIES, editedGroceries); // different date -> returns false - editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES) + editedGroceries = new TransactionBuilder(BUYING_GROCERIES) .withDateTime("01-01-1999 18:18") .build(); - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + assertNotEquals(BUYING_GROCERIES, editedGroceries); // different location -> returns false - editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withLocation("UTown").build(); - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withLocation("UTown").build(); + assertNotEquals(BUYING_GROCERIES, editedGroceries); // different transaction type -> return false - editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withType("expense").build(); - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES, editedGroceries); + editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withType("expense").build(); + assertNotEquals(BUYING_GROCERIES, editedGroceries); // different categories -> returns false - editedGroceries = new TransactionBuilder(TypicalTransactions.BUYING_GROCERIES).withCategories("TEST").build(); - Assertions.assertFalse(TypicalTransactions.BUYING_GROCERIES.equals(editedGroceries)); + editedGroceries = new TransactionBuilder(BUYING_GROCERIES).withCategories("TEST").build(); + assertFalse(BUYING_GROCERIES.equals(editedGroceries)); } @Test public void toStringMethod() { String expected = Transaction.class.getCanonicalName() - + "{name=" + TypicalTransactions.BUYING_GROCERIES.getName() - + ", type=" + TypicalTransactions.BUYING_GROCERIES.getType() - + ", amount=" + TypicalTransactions.BUYING_GROCERIES.getAmount() - + ", dateTime=" + TypicalTransactions.BUYING_GROCERIES.getDateTime() - + ", location=" + TypicalTransactions.BUYING_GROCERIES.getLocation() - + ", categories=" + TypicalTransactions.BUYING_GROCERIES.getCategories() + + "{name=" + BUYING_GROCERIES.getName() + + ", type=" + BUYING_GROCERIES.getType() + + ", amount=" + BUYING_GROCERIES.getAmount() + + ", dateTime=" + BUYING_GROCERIES.getDateTime() + + ", location=" + BUYING_GROCERIES.getLocation() + + ", categories=" + BUYING_GROCERIES.getCategories() + "}"; - Assertions.assertEquals(expected, TypicalTransactions.BUYING_GROCERIES.toString()); + assertEquals(expected, BUYING_GROCERIES.toString()); } @Test public void hashCode_test() { - Assertions.assertEquals(TypicalTransactions.BUYING_GROCERIES.hashCode(), TypicalTransactions.BUYING_GROCERIES.hashCode()); - Assertions.assertNotEquals(TypicalTransactions.BUYING_GROCERIES.hashCode(), TypicalTransactions.WORK_AT_LIHO.hashCode()); + assertEquals(BUYING_GROCERIES.hashCode(), BUYING_GROCERIES.hashCode()); + assertNotEquals(BUYING_GROCERIES.hashCode(), WORK_AT_LIHO.hashCode()); } } diff --git a/src/test/java/unicash/model/transaction/TypeTest.java b/src/test/java/unicash/model/transaction/TypeTest.java index 9fd3d3f1680..28b73c5643e 100644 --- a/src/test/java/unicash/model/transaction/TypeTest.java +++ b/src/test/java/unicash/model/transaction/TypeTest.java @@ -7,20 +7,19 @@ import static unicash.testutil.Assert.assertThrows; import org.junit.jupiter.api.Test; -import unicash.testutil.Assert; public class TypeTest { @Test public void constructor_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new Type(null)); + assertThrows(NullPointerException.class, () -> new Type(null)); } @Test public void constructor_invalidType_throwsIllegalArgumentException() { String[] invalidTypes = new String[] {"", "1", "Wrong"}; for (String invalidType: invalidTypes) { - Assert.assertThrows(IllegalArgumentException.class, () -> new Type(invalidType)); + assertThrows(IllegalArgumentException.class, () -> new Type(invalidType)); } } diff --git a/src/test/java/unicash/storage/JsonAdaptedTransactionTest.java b/src/test/java/unicash/storage/JsonAdaptedTransactionTest.java index d415b7342ab..79fba5bdd68 100644 --- a/src/test/java/unicash/storage/JsonAdaptedTransactionTest.java +++ b/src/test/java/unicash/storage/JsonAdaptedTransactionTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; +import static unicash.storage.JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT; import static unicash.testutil.Assert.assertThrows; import static unicash.testutil.TypicalTransactions.SHOPPING; @@ -19,7 +20,6 @@ import unicash.model.transaction.Transaction; import unicash.model.transaction.Type; import unicash.testutil.TransactionBuilder; -import unicash.testutil.Assert; public class JsonAdaptedTransactionTest { private static final String INVALID_NAME = "R@chel"; @@ -55,7 +55,7 @@ public void toModelType_invalidName_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Name.MESSAGE_CONSTRAINTS; - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -69,8 +69,8 @@ public void toModelType_nullName_throwsIllegalValueException() { VALID_CATEGORIES ); - String expectedMessage = String.format(JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -84,7 +84,7 @@ public void toModelType_invalidAmount_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Amount.MESSAGE_CONSTRAINTS; - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -99,7 +99,7 @@ public void toModelType_invalidCategories_throwsIllegalValueException() { VALID_LOCATION, VALID_TYPE, invalidCategories); - Assert.assertThrows(IllegalValueException.class, transaction::toModelType); + assertThrows(IllegalValueException.class, transaction::toModelType); } @Test @@ -139,7 +139,7 @@ public void toModelType_invalidDateTime_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = DateTime.MESSAGE_CONSTRAINTS; - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -152,8 +152,8 @@ public void toModelType_nullDateTime_throwsIllegalValueException() { VALID_TYPE, VALID_CATEGORIES ); - String expectedMessage = String.format(JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT, DateTime.class.getSimpleName()); - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, DateTime.class.getSimpleName()); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -167,7 +167,7 @@ public void toModelType_invalidLocation_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Location.MESSAGE_CONSTRAINTS; - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -181,7 +181,7 @@ public void toModelType_invalidType_throwsIllegalValueException() { VALID_CATEGORIES ); String expectedMessage = Type.MESSAGE_CONSTRAINTS; - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } @Test @@ -194,7 +194,7 @@ public void toModelType_nullType_throwsIllegalValueException() { null, VALID_CATEGORIES ); - String expectedMessage = String.format(JsonAdaptedTransaction.MISSING_FIELD_MESSAGE_FORMAT, Type.class.getSimpleName()); - Assert.assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Type.class.getSimpleName()); + assertThrows(IllegalValueException.class, expectedMessage, transaction::toModelType); } } diff --git a/src/test/java/unicash/storage/JsonUserPrefsStorageTest.java b/src/test/java/unicash/storage/JsonUserPrefsStorageTest.java index 13211c76de5..55d70eb62be 100644 --- a/src/test/java/unicash/storage/JsonUserPrefsStorageTest.java +++ b/src/test/java/unicash/storage/JsonUserPrefsStorageTest.java @@ -15,7 +15,7 @@ import unicash.commons.core.GuiSettings; import unicash.commons.exceptions.DataLoadingException; import unicash.model.UserPrefs; -import unicash.testutil.Assert; + public class JsonUserPrefsStorageTest { @@ -26,7 +26,7 @@ public class JsonUserPrefsStorageTest { @Test public void readUserPrefs_nullFilePath_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> readUserPrefs(null)); + assertThrows(NullPointerException.class, () -> readUserPrefs(null)); } private Optional readUserPrefs(String userPrefsFileInTestDataFolder) throws DataLoadingException { @@ -41,7 +41,7 @@ public void readUserPrefs_missingFile_emptyResult() throws DataLoadingException @Test public void readUserPrefs_notJsonFormat_exceptionThrown() { - Assert.assertThrows(DataLoadingException.class, () -> readUserPrefs("NotJsonFormatUserPrefs.json")); + assertThrows(DataLoadingException.class, () -> readUserPrefs("NotJsonFormatUserPrefs.json")); } private Path addToTestDataPathIfNotNull(String userPrefsFileInTestDataFolder) { @@ -80,12 +80,12 @@ private UserPrefs getTypicalUserPrefs() { @Test public void savePrefs_nullPrefs_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> saveUserPrefs(null, "SomeFile.json")); + assertThrows(NullPointerException.class, () -> saveUserPrefs(null, "SomeFile.json")); } @Test public void saveUserPrefs_nullFilePath_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> saveUserPrefs(new UserPrefs(), null)); + assertThrows(NullPointerException.class, () -> saveUserPrefs(new UserPrefs(), null)); } /** diff --git a/src/test/java/unicash/testutil/TransactionUtil.java b/src/test/java/unicash/testutil/TransactionUtil.java index a336c609249..bb86ac10078 100644 --- a/src/test/java/unicash/testutil/TransactionUtil.java +++ b/src/test/java/unicash/testutil/TransactionUtil.java @@ -1,12 +1,19 @@ package unicash.testutil; +import static unicash.logic.parser.CliSyntax.PREFIX_AMOUNT; +import static unicash.logic.parser.CliSyntax.PREFIX_CATEGORY; +import static unicash.logic.parser.CliSyntax.PREFIX_DATETIME; +import static unicash.logic.parser.CliSyntax.PREFIX_LOCATION; +import static unicash.logic.parser.CliSyntax.PREFIX_NAME; +import static unicash.logic.parser.CliSyntax.PREFIX_TYPE; + import java.util.Set; import unicash.logic.commands.AddTransactionCommand; import unicash.logic.commands.EditTransactionCommand; import unicash.model.category.Category; import unicash.model.transaction.Transaction; -import unicash.logic.parser.CliSyntax; + /** * A utility class for Transaction. @@ -25,35 +32,36 @@ public static String getAddTransactionCommand(Transaction transaction) { */ public static String getTransactionDetails(Transaction transaction) { StringBuilder sb = new StringBuilder(); - sb.append(CliSyntax.PREFIX_NAME).append(transaction.getName().fullName).append(" "); - sb.append(CliSyntax.PREFIX_TYPE).append(transaction.getType().type.getOriginalString()).append(" "); - sb.append(CliSyntax.PREFIX_AMOUNT).append(transaction.getAmount().toString()).append(" "); - sb.append(CliSyntax.PREFIX_DATETIME).append(transaction.getDateTime().originalString()).append(" "); - sb.append(CliSyntax.PREFIX_LOCATION).append(transaction.getLocation().location).append(" "); + sb.append(PREFIX_NAME).append(transaction.getName().fullName).append(" "); + sb.append(PREFIX_TYPE).append(transaction.getType().type.getOriginalString()).append(" "); + sb.append(PREFIX_AMOUNT).append(transaction.getAmount().toString()).append(" "); + sb.append(PREFIX_DATETIME).append(transaction.getDateTime().originalString()).append(" "); + sb.append(PREFIX_LOCATION).append(transaction.getLocation().location).append(" "); transaction.getCategories().forEach( - category -> sb.append(CliSyntax.PREFIX_CATEGORY).append(category.category).append(" ") + category -> sb.append(PREFIX_CATEGORY).append(category.category).append(" ") ); return sb.toString(); } - public static String getEditTransactionDescriptorDetails(EditTransactionCommand.EditTransactionDescriptor descriptor) { + public static String getEditTransactionDescriptorDetails(EditTransactionCommand + .EditTransactionDescriptor descriptor) { StringBuilder sb = new StringBuilder(); - descriptor.getName().ifPresent(name -> sb.append(CliSyntax.PREFIX_NAME).append(name.fullName) + descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName) .append(" ")); - descriptor.getType().ifPresent(type -> sb.append(CliSyntax.PREFIX_TYPE).append(type.type.getOriginalString()) + descriptor.getType().ifPresent(type -> sb.append(PREFIX_TYPE).append(type.type.getOriginalString()) .append(" ")); - descriptor.getAmount().ifPresent(amount -> sb.append(CliSyntax.PREFIX_AMOUNT).append(amount.amount) + descriptor.getAmount().ifPresent(amount -> sb.append(PREFIX_AMOUNT).append(amount.amount) .append(" ")); - descriptor.getLocation().ifPresent(location -> sb.append(CliSyntax.PREFIX_LOCATION).append(location) + descriptor.getLocation().ifPresent(location -> sb.append(PREFIX_LOCATION).append(location) .append(" ")); - descriptor.getDateTime().ifPresent(dateTime -> sb.append(CliSyntax.PREFIX_DATETIME).append(dateTime.originalString()) + descriptor.getDateTime().ifPresent(dateTime -> sb.append(PREFIX_DATETIME).append(dateTime.originalString()) .append(" ")); if (descriptor.getCategories().isPresent()) { Set categories = descriptor.getCategories().get(); if (categories.isEmpty()) { - sb.append(CliSyntax.PREFIX_CATEGORY); + sb.append(PREFIX_CATEGORY); } else { - categories.forEach(s -> sb.append(CliSyntax.PREFIX_CATEGORY).append(s.category).append(" ")); + categories.forEach(s -> sb.append(PREFIX_CATEGORY).append(s.category).append(" ")); } } return sb.toString(); diff --git a/src/test/java/unicash/testutil/TypicalTransactions.java b/src/test/java/unicash/testutil/TypicalTransactions.java index 5571a1f0f22..5d8135992a8 100644 --- a/src/test/java/unicash/testutil/TypicalTransactions.java +++ b/src/test/java/unicash/testutil/TypicalTransactions.java @@ -1,12 +1,28 @@ package unicash.testutil; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_INTERN; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_AMOUNT_SHOPPING; +import static unicash.logic.commands.CommandTestUtil.VALID_CATEGORY_EDUCATION; +import static unicash.logic.commands.CommandTestUtil.VALID_CATEGORY_ENTERTAINMENT; +import static unicash.logic.commands.CommandTestUtil.VALID_CATEGORY_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_DATETIME_INTERN; +import static unicash.logic.commands.CommandTestUtil.VALID_DATETIME_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_DATETIME_SHOPPING; +import static unicash.logic.commands.CommandTestUtil.VALID_LOCATION_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_LOCATION_ORCHARD; +import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_INTERN; +import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_NUS; +import static unicash.logic.commands.CommandTestUtil.VALID_TRANSACTION_NAME_SHOPPING; +import static unicash.logic.commands.CommandTestUtil.VALID_TYPE_EXPENSE; +import static unicash.logic.commands.CommandTestUtil.VALID_TYPE_INCOME; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; import unicash.model.UniCash; import unicash.model.transaction.Transaction; -import unicash.logic.commands.CommandTestUtil; /** * A utility class containing a list of {@code Transaction} objects to be used in tests. @@ -35,26 +51,26 @@ public class TypicalTransactions { .build(); // Manually added - Income's details found in {@code CommandTestUtil} - public static final Transaction NUS = new TransactionBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_NUS) - .withType(CommandTestUtil.VALID_TYPE_EXPENSE) - .withAmount(CommandTestUtil.VALID_AMOUNT_NUS) - .withDateTime(CommandTestUtil.VALID_DATETIME_NUS) - .withLocation(CommandTestUtil.VALID_LOCATION_NUS) - .withCategories(CommandTestUtil.VALID_CATEGORY_NUS) + public static final Transaction NUS = new TransactionBuilder().withName(VALID_TRANSACTION_NAME_NUS) + .withType(VALID_TYPE_EXPENSE) + .withAmount(VALID_AMOUNT_NUS) + .withDateTime(VALID_DATETIME_NUS) + .withLocation(VALID_LOCATION_NUS) + .withCategories(VALID_CATEGORY_NUS) .build(); - public static final Transaction INTERN = new TransactionBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_INTERN) - .withType(CommandTestUtil.VALID_TYPE_EXPENSE) - .withAmount(CommandTestUtil.VALID_AMOUNT_INTERN) - .withDateTime(CommandTestUtil.VALID_DATETIME_INTERN) - .withLocation(CommandTestUtil.VALID_LOCATION_ORCHARD) + public static final Transaction INTERN = new TransactionBuilder().withName(VALID_TRANSACTION_NAME_INTERN) + .withType(VALID_TYPE_EXPENSE) + .withAmount(VALID_AMOUNT_INTERN) + .withDateTime(VALID_DATETIME_INTERN) + .withLocation(VALID_LOCATION_ORCHARD) .build(); - public static final Transaction SHOPPING = new TransactionBuilder().withName(CommandTestUtil.VALID_TRANSACTION_NAME_SHOPPING) - .withType(CommandTestUtil.VALID_TYPE_INCOME) - .withAmount(CommandTestUtil.VALID_AMOUNT_SHOPPING) - .withDateTime(CommandTestUtil.VALID_DATETIME_SHOPPING) - .withLocation(CommandTestUtil.VALID_LOCATION_ORCHARD) - .withCategories(CommandTestUtil.VALID_CATEGORY_ENTERTAINMENT, CommandTestUtil.VALID_CATEGORY_EDUCATION) + public static final Transaction SHOPPING = new TransactionBuilder().withName(VALID_TRANSACTION_NAME_SHOPPING) + .withType(VALID_TYPE_INCOME) + .withAmount(VALID_AMOUNT_SHOPPING) + .withDateTime(VALID_DATETIME_SHOPPING) + .withLocation(VALID_LOCATION_ORCHARD) + .withCategories(VALID_CATEGORY_ENTERTAINMENT, VALID_CATEGORY_EDUCATION) .build(); /** * Returns a {@code UniCash} with all the typical transactions. diff --git a/src/test/java/unicash/ui/UiPartTest.java b/src/test/java/unicash/ui/UiPartTest.java index a599d5ce5ba..04b4963a8ae 100644 --- a/src/test/java/unicash/ui/UiPartTest.java +++ b/src/test/java/unicash/ui/UiPartTest.java @@ -12,7 +12,6 @@ import javafx.fxml.FXML; import unicash.MainApp; -import unicash.testutil.Assert; public class UiPartTest { @@ -27,22 +26,22 @@ public class UiPartTest { @Test public void constructor_nullFileUrl_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null)); - Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null, new Object())); + assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null)); + assertThrows(NullPointerException.class, () -> new TestUiPart((URL) null, new Object())); } @Test public void constructor_missingFileUrl_throwsAssertionError() throws Exception { URL missingFileUrl = new URL(testFolder.toUri().toURL(), MISSING_FILE_PATH); - Assert.assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl)); - Assert.assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl, new Object())); + assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl)); + assertThrows(AssertionError.class, () -> new TestUiPart(missingFileUrl, new Object())); } @Test public void constructor_invalidFileUrl_throwsAssertionError() { URL invalidFileUrl = getTestFileUrl(INVALID_FILE_PATH); - Assert.assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl)); - Assert.assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl, new Object())); + assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl)); + assertThrows(AssertionError.class, () -> new TestUiPart(invalidFileUrl, new Object())); } @Test @@ -60,20 +59,20 @@ public void constructor_validFileWithFxRootUrl_loadsFile() { @Test public void constructor_nullFileName_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((String) null)); - Assert.assertThrows(NullPointerException.class, () -> new TestUiPart((String) null, new Object())); + assertThrows(NullPointerException.class, () -> new TestUiPart((String) null)); + assertThrows(NullPointerException.class, () -> new TestUiPart((String) null, new Object())); } @Test public void constructor_missingFileName_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH)); - Assert.assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH, new Object())); + assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH)); + assertThrows(NullPointerException.class, () -> new TestUiPart(MISSING_FILE_PATH, new Object())); } @Test public void constructor_invalidFileName_throwsAssertionError() { - Assert.assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH)); - Assert.assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH, new Object())); + assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH)); + assertThrows(AssertionError.class, () -> new TestUiPart(INVALID_FILE_PATH, new Object())); } private URL getTestFileUrl(String testFilePath) {