Skip to content

Commit

Permalink
Add test & docs (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmadHatziq committed Nov 11, 2019
1 parent 90e23e4 commit 7618a5b
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 17 deletions.
19 changes: 2 additions & 17 deletions docs/team/ahmadhatziq.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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

|===
Expand All @@ -109,7 +97,7 @@ include::../UserGuide.adoc[tag=FeatureAddModule]

include::../UserGuide.adoc[tag=FeatureAddTutorial]


=======
== Contributions to the Developer Guide
|===
Expand All @@ -119,9 +107,6 @@ include::../UserGuide.adoc[tag=FeatureAddTutorial]
=======
include::../DeveloperGuide.adoc[tag=undoredo]

include::../DeveloperGuide.adoc[tag=storage]
=======


* *Code contributed*:
Expand Down
Binary file added docs/team/ahmadhatziq.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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));
}


}
Original file line number Diff line number Diff line change
@@ -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));

}


}

Original file line number Diff line number Diff line change
@@ -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));

}
}

0 comments on commit 7618a5b

Please sign in to comment.