From 668c177859543ef91dba87cfd6375644f8e8d844 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 17 Oct 2024 21:56:24 +0800 Subject: [PATCH 1/2] Fix bug where tutors are saved wrongly to disk --- src/main/java/seedu/address/storage/JsonAdaptedPerson.java | 4 +++- .../seedu/address/storage/JsonAddressBookStorageTest.java | 1 - src/test/java/seedu/address/storage/StorageManagerTest.java | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 18fa80e1d71..3856ed7121b 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -3,9 +3,11 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -159,7 +161,7 @@ public Person toModelType() throws IllegalValueException { final Hours modelHours = new Hours(hours); final Set modelTags = new HashSet<>(tuteeTags); - if (role == "Tutor") { + if (Objects.equals(role,"Tutor")) { return new Tutor(modelName, modelPhone, modelEmail, modelAddress, modelHours, modelTags); } else { return new Tutee(modelName, modelPhone, modelEmail, modelAddress, modelHours, modelTags); diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java index 760c9b1a233..456cb1a5a61 100644 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java @@ -61,7 +61,6 @@ public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingExc assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonAddressBook.json")); } - @Disabled @Test public void readAndSaveAddressBook_allInOrder_success() throws Exception { Path filePath = testFolder.resolve("TempAddressBook.json"); diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 21341b923c0..58aafc05ad4 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -48,7 +48,6 @@ public void prefsReadSave() throws Exception { assertEquals(original, retrieved); } - @Disabled @Test public void addressBookReadSave() throws Exception { /* From 36b267d48eed8a3b1a7733da878e72f2987640e4 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 17 Oct 2024 22:15:11 +0800 Subject: [PATCH 2/2] Fix checkstyle --- src/main/java/seedu/address/storage/JsonAdaptedPerson.java | 3 +-- .../java/seedu/address/storage/JsonAddressBookStorageTest.java | 1 - src/test/java/seedu/address/storage/StorageManagerTest.java | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 3856ed7121b..d646e82edba 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -7,7 +7,6 @@ import java.util.Set; import java.util.stream.Collectors; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -161,7 +160,7 @@ public Person toModelType() throws IllegalValueException { final Hours modelHours = new Hours(hours); final Set modelTags = new HashSet<>(tuteeTags); - if (Objects.equals(role,"Tutor")) { + if (Objects.equals(role, "Tutor")) { return new Tutor(modelName, modelPhone, modelEmail, modelAddress, modelHours, modelTags); } else { return new Tutee(modelName, modelPhone, modelEmail, modelAddress, modelHours, modelTags); diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java index 456cb1a5a61..4e5ce9200c8 100644 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java @@ -12,7 +12,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 58aafc05ad4..99a16548970 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -7,7 +7,6 @@ import java.nio.file.Path; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir;