diff --git a/docs/team/ahmadhatziq.adoc b/docs/team/ahmadhatziq.adoc index bcbce95e553..b400e975afb 100644 --- a/docs/team/ahmadhatziq.adoc +++ b/docs/team/ahmadhatziq.adoc @@ -54,10 +54,6 @@ collaboration with other components of the application was highly needed. ** The implementation too was challenging as it required to work with a variety of data structures, so as to maintain the efficiency and effectiveness of data processing. ** Given the many layers of information contained within T.A.rence, information had to carefully extracted without compromising other related systems. -* Credits: -** Code on changing a hash-map to a tree-map is obtained from here {https://www.geeksforgeeks.org/program-to-convert-hashmap-to-treemap-in-java/} - - === *Major Enhancement*: added *Undo command* * Summary of the features: @@ -68,17 +64,13 @@ collaboration with other components of the application was highly needed. * Highlights: ** This enhancement is different from the one suggested in AB3. -+ During the operation of the application, temporary state files will be stored on the hard +During the operation of the application, temporary state files will be stored on the hard disk. This modification allows for multiple states to be stored, without affecting valuable RAM. ** Once an undo command is executed, the previous state is then loaded into the system memory from the saved json state file. -** The implementation too was challenging as it involves proper serializing and de-serializing -of the json file, properly ensuring that a state change is reflected correctly and loading the data -from json and re-creating the proper specified model. - === *Minor Enhancement*: added commands for "addModule" and "addTutorial". ** Added the basic skeleton functionality for TArence. @@ -89,10 +81,6 @@ from json and re-creating the proper specified model. *** Used Github for milestone, bug and issue tracking *** Assisted to review peer code before merging -** Documentation: -*** Edited User Guide: link:{prURL}/27[#27] -*** Edited Developer Guide: link:{prURL}/27[#27], link:{prURL}/93[#93] - == Contributions to the User Guide |=== @@ -109,7 +97,7 @@ include::../UserGuide.adoc[tag=FeatureAddModule] include::../UserGuide.adoc[tag=FeatureAddTutorial] - +======= == Contributions to the Developer Guide |=== @@ -119,9 +107,6 @@ include::../UserGuide.adoc[tag=FeatureAddTutorial] ======= include::../DeveloperGuide.adoc[tag=undoredo] -include::../DeveloperGuide.adoc[tag=storage] - -======= * *Code contributed*: diff --git a/docs/team/ahmadhatziq.pdf b/docs/team/ahmadhatziq.pdf new file mode 100644 index 00000000000..c01511da6d8 Binary files /dev/null and b/docs/team/ahmadhatziq.pdf differ diff --git a/src/test/java/seedu/tarence/logic/commands/AddModuleCommandTest.java b/src/test/java/seedu/tarence/logic/commands/AddModuleCommandTest.java new file mode 100644 index 00000000000..274e97441de --- /dev/null +++ b/src/test/java/seedu/tarence/logic/commands/AddModuleCommandTest.java @@ -0,0 +1,46 @@ +package seedu.tarence.logic.commands; + +import static seedu.tarence.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.tarence.testutil.Assert.assertThrows; +import static seedu.tarence.testutil.TypicalPersons.getTypicalApplication; + +import org.junit.jupiter.api.Test; + +import seedu.tarence.model.Model; +import seedu.tarence.model.ModelManager; +import seedu.tarence.model.UserPrefs; +import seedu.tarence.model.builder.ModuleBuilder; +import seedu.tarence.model.module.Module; +import seedu.tarence.model.module.exceptions.DuplicateModuleException; + +public class AddModuleCommandTest { + public static final String VALID_MOD_CODE = "GER1000"; + + @Test + public void execute_correctArguments_moduleAdded() { + Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); + Model expectedModel = new ModelManager(getTypicalApplication(), new UserPrefs()); + Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); + + expectedModel.addModule(validModule); + + assertCommandSuccess(new AddModuleCommand(validModule), model, + String.format(AddModuleCommand.MESSAGE_SUCCESS, validModule), expectedModel); + } + + @Test + public void constructor_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> new AddModuleCommand(null)); + } + + @Test + public void execute_duplicateModule_throwsDuplicateException() { + Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); + Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); + model.addModule(validModule); + + assertThrows(DuplicateModuleException.class, () -> model.addModule(validModule)); + } + + +} diff --git a/src/test/java/seedu/tarence/logic/commands/DeleteModuleVerifiedCommandTest.java b/src/test/java/seedu/tarence/logic/commands/DeleteModuleVerifiedCommandTest.java new file mode 100644 index 00000000000..1df869efc00 --- /dev/null +++ b/src/test/java/seedu/tarence/logic/commands/DeleteModuleVerifiedCommandTest.java @@ -0,0 +1,64 @@ +package seedu.tarence.logic.commands; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import static seedu.tarence.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.tarence.testutil.TypicalPersons.getTypicalApplication; + +import org.junit.jupiter.api.Test; + +import seedu.tarence.model.Model; +import seedu.tarence.model.ModelManager; +import seedu.tarence.model.UserPrefs; +import seedu.tarence.model.builder.ModuleBuilder; +import seedu.tarence.model.module.Module; + +public class DeleteModuleVerifiedCommandTest { + + + public static final String VALID_MOD_CODE = "GER1000"; + + @Test + public void execute_model_moduleDeleted() { + ModuleBuilder.DEFAULT_TUTORIALS.clear(); + Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); + Model expectedModel = new ModelManager(getTypicalApplication(), new UserPrefs()); + Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); + model.addModule(validModule); + + + assertCommandSuccess(new DeleteModuleVerifiedCommand(validModule), model, + "Deleted Module: " + VALID_MOD_CODE + " | ", expectedModel); + } + + @Test + public void needsInput_returnsTrue() { + Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); + DeleteModuleVerifiedCommand deleteModuleVerifiedCommand = new DeleteModuleVerifiedCommand(validModule); + + assertTrue(deleteModuleVerifiedCommand.needsInput()); + } + + @Test + public void needsCommand_confirmsYesCommand_returnsTrue() { + Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); + DeleteModuleVerifiedCommand deleteModuleVerifiedCommand = new DeleteModuleVerifiedCommand(validModule); + + ConfirmNoCommand confirmNoCommand = new ConfirmNoCommand(); + + assertTrue(deleteModuleVerifiedCommand.needsCommand(confirmNoCommand)); + + } + + @Test + public void needsCommand_confirmNoCommand_returnsTrue() { + Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); + DeleteModuleVerifiedCommand deleteModuleVerifiedCommand = new DeleteModuleVerifiedCommand(validModule); + ConfirmYesCommand confirmYesCommand = new ConfirmYesCommand(); + assertTrue(deleteModuleVerifiedCommand.needsCommand(confirmYesCommand)); + + } + + +} + diff --git a/src/test/java/seedu/tarence/logic/commands/DeleteTutorialVerifiedCommandTest.java b/src/test/java/seedu/tarence/logic/commands/DeleteTutorialVerifiedCommandTest.java new file mode 100644 index 00000000000..125d760e86c --- /dev/null +++ b/src/test/java/seedu/tarence/logic/commands/DeleteTutorialVerifiedCommandTest.java @@ -0,0 +1,73 @@ +package seedu.tarence.logic.commands; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.tarence.logic.commands.CommandTestUtil.VALID_MODULE_AMY; +import static seedu.tarence.logic.commands.CommandTestUtil.VALID_TUTORIAL_NAME_AMY; +import static seedu.tarence.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.tarence.testutil.TypicalPersons.getTypicalApplication; + +import org.junit.jupiter.api.Test; + +import seedu.tarence.model.Model; +import seedu.tarence.model.ModelManager; +import seedu.tarence.model.UserPrefs; +import seedu.tarence.model.builder.ModuleBuilder; +import seedu.tarence.model.builder.TutorialBuilder; +import seedu.tarence.model.module.Module; +import seedu.tarence.model.tutorial.Tutorial; + +public class DeleteTutorialVerifiedCommandTest { + + @Test + public void execute_model_tutorialToBeDeleted() { + ModuleBuilder.DEFAULT_TUTORIALS.clear(); + TutorialBuilder.DEFAULT_STUDENTS.clear(); + Module validModule = new ModuleBuilder().withModCode(VALID_MODULE_AMY).build(); + Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) + .withModCode(VALID_MODULE_AMY).build(); + + Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); + Model expectedModel = new ModelManager(getTypicalApplication(), new UserPrefs()); + + expectedModel.addModule(validModule); + model.addModule(validModule); + + model.addTutorial(validTutorial); + model.addTutorialToModule(validTutorial); + + assertCommandSuccess(new DeleteTutorialVerifiedCommand(validTutorial), model, + "Deleted Tutorial: " + validTutorial.toString(), expectedModel); + + } + + @Test + public void needsInput_returnsTrue() { + Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) + .withModCode(VALID_MODULE_AMY).build(); + DeleteTutorialVerifiedCommand deleteTutorialVerifiedCommand = new DeleteTutorialVerifiedCommand(validTutorial); + + assertTrue(deleteTutorialVerifiedCommand.needsInput()); + } + + @Test + public void needsCommand_confirmsYesCommand_returnsTrue() { + Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) + .withModCode(VALID_MODULE_AMY).build(); + DeleteTutorialVerifiedCommand deleteTutorialVerifiedCommand = new DeleteTutorialVerifiedCommand(validTutorial); + + ConfirmNoCommand confirmNoCommand = new ConfirmNoCommand(); + + assertTrue(deleteTutorialVerifiedCommand.needsCommand(confirmNoCommand)); + + } + + @Test + public void needsCommand_confirmNoCommand_returnsTrue() { + Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) + .withModCode(VALID_MODULE_AMY).build(); + DeleteTutorialVerifiedCommand deleteTutorialVerifiedCommand = new DeleteTutorialVerifiedCommand(validTutorial); + ConfirmYesCommand confirmYesCommand = new ConfirmYesCommand(); + assertTrue(deleteTutorialVerifiedCommand.needsCommand(confirmYesCommand)); + + } +}