diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java
index fdffd1a68c2..4950e564d63 100644
--- a/src/test/java/seedu/address/logic/LogicManagerTest.java
+++ b/src/test/java/seedu/address/logic/LogicManagerTest.java
@@ -91,6 +91,27 @@ public void getFilteredCustomerList_modifyList_throwsUnsupportedOperationExcepti
assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredCustomerList().remove(0));
}
+ @Test
+ public void getAddressBookMethod() {
+ assertEquals(logic.getAddressBook(), model.getAddressBook());
+ }
+
+ @Test
+ public void getAddressBookFilePathMethod() {
+ assertEquals(logic.getAddressBookFilePath(), model.getAddressBookFilePath());
+ }
+
+ @Test
+ public void getGuiSettingsMethod() {
+ assertEquals(logic.getGuiSettings(), model.getGuiSettings());
+ }
+
+ @Test
+ public void setGuiSettingsMethod() {
+ logic.getGuiSettings();
+ model.getGuiSettings();
+ assertEquals(logic.getGuiSettings(), model.getGuiSettings());
+ }
/**
* Executes the command and confirms that
* - no exceptions are thrown
diff --git a/src/test/java/seedu/address/logic/commands/AddCustomerCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddCustomerCommandIntegrationTest.java
index 7d192ca3f73..59d4b139622 100644
--- a/src/test/java/seedu/address/logic/commands/AddCustomerCommandIntegrationTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddCustomerCommandIntegrationTest.java
@@ -10,6 +10,7 @@
import seedu.address.logic.Messages;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
+import seedu.address.model.PropertyBook;
import seedu.address.model.UserPrefs;
import seedu.address.model.customer.Customer;
import seedu.address.testutil.CustomerBuilder;
@@ -23,14 +24,14 @@ public class AddCustomerCommandIntegrationTest {
@BeforeEach
public void setUp() {
- model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ model = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
}
@Test
public void execute_newCustomer_success() {
Customer validCustomer = new CustomerBuilder().build();
- Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ Model expectedModel = new ModelManager(model.getAddressBook(), new PropertyBook(), new UserPrefs());
expectedModel.addCustomer(validCustomer);
assertCommandSuccess(new AddCustomerCommand(validCustomer), model,
diff --git a/src/test/java/seedu/address/logic/commands/AddCustomerCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCustomerCommandTest.java
index 2ea779bccaa..b6eb17fe526 100644
--- a/src/test/java/seedu/address/logic/commands/AddCustomerCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddCustomerCommandTest.java
@@ -21,8 +21,10 @@
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
+import seedu.address.model.ReadOnlyPropertyBook;
import seedu.address.model.ReadOnlyUserPrefs;
import seedu.address.model.customer.Customer;
+import seedu.address.model.property.Property;
import seedu.address.testutil.CustomerBuilder;
public class AddCustomerCommandTest {
@@ -114,50 +116,99 @@ public Path getAddressBookFilePath() {
throw new AssertionError("This method should not be called.");
}
+ public Path getPropertyBookFilePath() {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void setAddressBookFilePath(Path addressBookFilePath) {
throw new AssertionError("This method should not be called.");
}
+ public void setPropertyBookFilePath(Path propertyBookFilePath) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void addCustomer(Customer customer) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void addProperty(Property property) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void setAddressBook(ReadOnlyAddressBook newData) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void setPropertyBook(ReadOnlyPropertyBook newData) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public ReadOnlyAddressBook getAddressBook() {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public ReadOnlyPropertyBook getPropertyBook() {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public boolean hasCustomer(Customer customer) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public boolean hasProperty(Property property) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void deleteCustomer(Customer target) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void deleteProperty(Property target) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void setCustomer(Customer target, Customer editedCustomer) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void setProperty(Property target, Property editedProperty) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+
@Override
public ObservableList getFilteredCustomerList() {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public ObservableList getFilteredPropertyList() {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void updateFilteredCustomerList(Predicate predicate) {
throw new AssertionError("This method should not be called.");
}
+
+ @Override
+ public void updateFilteredPropertyList(Predicate predicate) {
+ throw new AssertionError("This method should not be called.");
+ }
}
/**
diff --git a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java
index dda0f3e4cab..036a49fccea 100644
--- a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java
@@ -8,6 +8,7 @@
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
+import seedu.address.model.PropertyBook;
import seedu.address.model.UserPrefs;
public class ClearCommandTest {
@@ -22,8 +23,8 @@ public void execute_emptyAddressBook_success() {
@Test
public void execute_nonEmptyAddressBook_success() {
- Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
- Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ Model model = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
+ Model expectedModel = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
expectedModel.setAddressBook(new AddressBook());
assertCommandSuccess(new ClearCommand(), model, ClearCommand.MESSAGE_SUCCESS, expectedModel);
diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java
index f54d402ee46..afd10037b4c 100644
--- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java
@@ -16,6 +16,7 @@
import seedu.address.logic.Messages;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
+import seedu.address.model.PropertyBook;
import seedu.address.model.UserPrefs;
import seedu.address.model.customer.Customer;
@@ -25,7 +26,7 @@
*/
public class DeleteCommandTest {
- private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ private Model model = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
@Test
public void execute_validIndexUnfilteredList_success() {
@@ -35,7 +36,7 @@ public void execute_validIndexUnfilteredList_success() {
String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_CUSTOMER_SUCCESS,
Messages.format(customerToDelete));
- ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ ModelManager expectedModel = new ModelManager(model.getAddressBook(), new PropertyBook(), new UserPrefs());
expectedModel.deleteCustomer(customerToDelete);
assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
@@ -59,7 +60,7 @@ public void execute_validIndexFilteredList_success() {
String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_CUSTOMER_SUCCESS,
Messages.format(customerToDelete));
- Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ Model expectedModel = new ModelManager(model.getAddressBook(), new PropertyBook(), new UserPrefs());
expectedModel.deleteCustomer(customerToDelete);
showNoCustomer(expectedModel);
diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java
index 893567ae7cc..27b42713546 100644
--- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java
@@ -23,6 +23,7 @@
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
+import seedu.address.model.PropertyBook;
import seedu.address.model.UserPrefs;
import seedu.address.model.customer.Customer;
import seedu.address.testutil.CustomerBuilder;
@@ -33,7 +34,7 @@
*/
public class EditCommandTest {
- private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ private Model model = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
@Test
public void execute_allFieldsSpecifiedUnfilteredList_success() {
@@ -44,7 +45,8 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() {
String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_CUSTOMER_SUCCESS,
Messages.format(editedCustomer));
- Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs());
+ Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
+ new PropertyBook(), new UserPrefs());
expectedModel.setCustomer(model.getFilteredCustomerList().get(0), editedCustomer);
assertCommandSuccess(editCommand, model, expectedMessage, expectedModel);
@@ -66,7 +68,8 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() {
String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_CUSTOMER_SUCCESS,
Messages.format(editedCustomer));
- Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs());
+ Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
+ new PropertyBook(), new UserPrefs());
expectedModel.setCustomer(lastCustomer, editedCustomer);
assertCommandSuccess(editCommand, model, expectedMessage, expectedModel);
@@ -80,7 +83,8 @@ public void execute_noFieldSpecifiedUnfilteredList_success() {
String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_CUSTOMER_SUCCESS,
Messages.format(editedCustomer));
- Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs());
+ Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
+ new PropertyBook(), new UserPrefs());
assertCommandSuccess(editCommand, model, expectedMessage, expectedModel);
}
@@ -97,7 +101,8 @@ public void execute_filteredList_success() {
String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_CUSTOMER_SUCCESS,
Messages.format(editedCustomer));
- Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs());
+ Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()),
+ new PropertyBook(), new UserPrefs());
expectedModel.setCustomer(model.getFilteredCustomerList().get(0), editedCustomer);
assertCommandSuccess(editCommand, model, expectedMessage, expectedModel);
diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java
index c547be33c41..a1b30ab0b6a 100644
--- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java
@@ -17,6 +17,7 @@
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
+import seedu.address.model.PropertyBook;
import seedu.address.model.UserPrefs;
import seedu.address.model.customer.NameContainsKeywordsPredicate;
@@ -24,8 +25,8 @@
* Contains integration tests (interaction with the Model) for {@code FindCommand}.
*/
public class FindCommandTest {
- private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
- private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ private Model model = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
+ private Model expectedModel = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
@Test
public void equals() {
diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java
index 8330ad71ed0..46d620abb97 100644
--- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java
@@ -10,6 +10,7 @@
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
+import seedu.address.model.PropertyBook;
import seedu.address.model.UserPrefs;
/**
@@ -22,8 +23,8 @@ public class ListCommandTest {
@BeforeEach
public void setUp() {
- model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
- expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ model = new ModelManager(getTypicalAddressBook(), new PropertyBook(), new UserPrefs());
+ expectedModel = new ModelManager(model.getAddressBook(), new PropertyBook(), new UserPrefs());
}
@Test
diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java
index 9984997b8aa..0597dd9f1ba 100644
--- a/src/test/java/seedu/address/model/ModelManagerTest.java
+++ b/src/test/java/seedu/address/model/ModelManagerTest.java
@@ -100,8 +100,8 @@ public void equals() {
UserPrefs userPrefs = new UserPrefs();
// same values -> returns true
- modelManager = new ModelManager(addressBook, userPrefs);
- ModelManager modelManagerCopy = new ModelManager(addressBook, userPrefs);
+ modelManager = new ModelManager(addressBook, new PropertyBook(), userPrefs);
+ ModelManager modelManagerCopy = new ModelManager(addressBook, new PropertyBook(), userPrefs);
assertTrue(modelManager.equals(modelManagerCopy));
// same object -> returns true
@@ -114,12 +114,12 @@ public void equals() {
assertFalse(modelManager.equals(5));
// different addressBook -> returns false
- assertFalse(modelManager.equals(new ModelManager(differentAddressBook, userPrefs)));
+ assertFalse(modelManager.equals(new ModelManager(differentAddressBook, new PropertyBook(), userPrefs)));
// different filteredList -> returns false
String[] keywords = ALICE.getName().fullName.split("\\s+");
modelManager.updateFilteredCustomerList(new NameContainsKeywordsPredicate(Arrays.asList(keywords)));
- assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs)));
+ assertFalse(modelManager.equals(new ModelManager(addressBook, new PropertyBook(), userPrefs)));
// resets modelManager to initial state for upcoming tests
modelManager.updateFilteredCustomerList(PREDICATE_SHOW_ALL_CUSTOMERS);
@@ -127,6 +127,6 @@ public void equals() {
// different userPrefs -> returns false
UserPrefs differentUserPrefs = new UserPrefs();
differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath"));
- assertFalse(modelManager.equals(new ModelManager(addressBook, differentUserPrefs)));
+ assertFalse(modelManager.equals(new ModelManager(addressBook, new PropertyBook(), differentUserPrefs)));
}
}
diff --git a/src/test/java/seedu/address/model/customer/BudgetTest.java b/src/test/java/seedu/address/model/customer/BudgetTest.java
new file mode 100644
index 00000000000..38ab9bd1948
--- /dev/null
+++ b/src/test/java/seedu/address/model/customer/BudgetTest.java
@@ -0,0 +1,69 @@
+package seedu.address.model.customer;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static seedu.address.testutil.Assert.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+
+public class BudgetTest {
+ private static final float OTHER_TYPE_INVALID_BUDGET = 5.0f;
+ private static final String NOT_INTEGER_INVALID_BUDGET = "one million";
+ private static final String ONE_DIGIT_INVALID_BUDGET = "1";
+ private static final String TWO_DIGIT_INVALID_BUDGET = "11";
+ private static final String THREE_DIGIT_INVALID_BUDGET = "111";
+ private static final String FOUR_DIGIT_INVALID_BUDGET = "1111";
+ private static final String VALID_BUDGET = "100000";
+ private static final String LONG_VALID_BUDGET = Integer.toString(Integer.MAX_VALUE);
+ @Test
+ public void constructor_null_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> new Budget(null));
+ }
+
+ @Test
+ public void constructor_invalidBudget_throwsIllegalArgumentException() {
+ String invalidBudget = "";
+ assertThrows(IllegalArgumentException.class, () -> new Budget(invalidBudget));
+ }
+
+ @Test
+ public void isValidBudget() {
+ // null budget
+ assertThrows(NullPointerException.class, () -> Budget.isValidBudget(null));
+
+ // invalid budgets
+ assertFalse(Budget.isValidBudget("")); // empty string
+ assertFalse(Budget.isValidBudget(" ")); // spaces only
+ assertFalse(Budget.isValidBudget(NOT_INTEGER_INVALID_BUDGET)); // not an integer
+ assertFalse(Budget.isValidBudget(ONE_DIGIT_INVALID_BUDGET)); // one digit only
+ assertFalse(Budget.isValidBudget(TWO_DIGIT_INVALID_BUDGET)); // two digit only
+ assertFalse(Budget.isValidBudget(THREE_DIGIT_INVALID_BUDGET)); // three digit only
+ assertFalse(Budget.isValidBudget(FOUR_DIGIT_INVALID_BUDGET)); // four digit only
+
+
+ // valid budgets
+ assertTrue(Budget.isValidBudget(VALID_BUDGET));
+ assertTrue(Budget.isValidBudget(LONG_VALID_BUDGET)); // long budget
+ }
+
+ @Test
+ public void equals() {
+ Budget budget = new Budget(VALID_BUDGET);
+
+ // same values -> returns true
+ assertTrue(budget.equals(new Budget(VALID_BUDGET)));
+
+ // same object -> returns true
+ assertTrue(budget.equals(budget));
+
+ // null -> returns false
+ assertFalse(budget.equals(null));
+
+ // different types -> returns false
+ assertFalse(budget.equals(OTHER_TYPE_INVALID_BUDGET));
+
+ // different values -> returns false
+ assertFalse(budget.equals(new Budget(LONG_VALID_BUDGET)));
+ }
+}
diff --git a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java b/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java
index ed0a413526a..c92400d4ece 100644
--- a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java
+++ b/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java
@@ -120,4 +120,9 @@ public void saveUserPrefs_allInOrder_success() throws DataLoadingException, IOEx
assertEquals(original, readBack);
}
+ @Test
+ public void getUserPrefsFilePathMethod() {
+ assertEquals(new JsonUserPrefsStorage(TEST_DATA_FOLDER).getUserPrefsFilePath(), TEST_DATA_FOLDER);
+ }
+
}
diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java
index f9cdebf0c94..eb8a4db7d8a 100644
--- a/src/test/java/seedu/address/storage/StorageManagerTest.java
+++ b/src/test/java/seedu/address/storage/StorageManagerTest.java
@@ -26,7 +26,7 @@ public class StorageManagerTest {
public void setUp() {
JsonAddressBookStorage addressBookStorage = new JsonAddressBookStorage(getTempFilePath("ab"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs"));
- storageManager = new StorageManager(addressBookStorage, userPrefsStorage);
+ storageManager = new StorageManager(addressBookStorage, null, userPrefsStorage);
}
private Path getTempFilePath(String fileName) {
@@ -65,4 +65,9 @@ public void getAddressBookFilePath() {
assertNotNull(storageManager.getAddressBookFilePath());
}
+ @Test
+ public void getUserPrefsFilePath() {
+ assertEquals(storageManager.getUserPrefsFilePath(),
+ new JsonUserPrefsStorage(getTempFilePath("prefs")).getUserPrefsFilePath());
+ }
}