Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-T13-0#235 from xCOLOURx/branch-ad…
Browse files Browse the repository at this point in the history
…d-mps-test

Add Test for ModulePlan Package
  • Loading branch information
marquestye authored Nov 12, 2023
2 parents 9aeb34c + a43d599 commit d26e026
Show file tree
Hide file tree
Showing 19 changed files with 751 additions and 84 deletions.
24 changes: 2 additions & 22 deletions src/main/java/seedu/address/model/moduleplan/ModulePlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
*/
public class ModulePlan implements ReadOnlyModulePlan {

private final ModulePlanSemesterList semesters;

{
semesters = new ModulePlanSemesterList();
}
private final ModulePlanSemesterList semesters = new ModulePlanSemesterList();


/**
* Creates a new empty ModulePlan.
Expand Down Expand Up @@ -54,24 +52,6 @@ public void setSemesters(List<ModulePlanSemester> semesters) {
this.semesters.setSemesters(semesters);
}

/**
* Adds a new semester to the module plan.
*
* @param semester The semester to be added.
*/
public void addSemester(ModulePlanSemester semester) {
this.semesters.addSemester(semester);
}

/**
* Removes a semester from the module plan.
*
* @param semester The semester to be removed.
*/
public void removeSemester(ModulePlanSemester semester) {
this.semesters.removeSemester(semester);
}


//// module-level operations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
*/
public class ModulePlanSemester implements Comparable<ModulePlanSemester> {

private final UniqueModuleList modules;
private final Year year;
private final Semester semester;

{
modules = new UniqueModuleList();
}
private Year year;
private Semester semester;

private final UniqueModuleList modules = new UniqueModuleList();

/**
* Wraps all data at the Module Plan semester level.
*/
public ModulePlanSemester(Year year, Semester semester) {
requireNonNull(year);
requireNonNull(semester);
this.year = year;
this.semester = semester;
}
Expand All @@ -37,6 +37,7 @@ public ModulePlanSemester(Year year, Semester semester) {
* Replaces the contents of the module list with {@code modules}.
*/
public void setModules(List<Module> modules) {
requireNonNull(modules);
this.modules.setModules(modules);
}

Expand All @@ -54,13 +55,15 @@ public boolean hasModule(Module m) {
* Adds a module to the module plan.
*/
public void addModule(Module m) {
requireNonNull(m);
modules.add(m);
}

/**
* Removes {@code key} from this {@code ModulePlan}.
*/
public void removeModule(Module key) {
requireNonNull(key);
modules.remove(key);
}

Expand Down Expand Up @@ -111,6 +114,8 @@ public Float totalValidMcs() {
* @return Whether the module is among the modules in this semester or not.
*/
public boolean checkModuleBelongToSemester(Module m) {
requireNonNull(m);

boolean equalYear = this.year.equals(m.getYearTaken());
boolean equalSemester = this.semester.equals(m.getSemesterTaken());

Expand All @@ -126,6 +131,8 @@ public boolean checkModuleBelongToSemester(Module m) {
* Checks if the given semester is the same semesters.
*/
public boolean checkIfSameSemester(ModulePlanSemester otherModulePlanSemester) {
requireNonNull(otherModulePlanSemester);

boolean yearEquals = this.year.equals(otherModulePlanSemester.year);
boolean semesterEquals = this.semester.equals(otherModulePlanSemester.semester);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public class DuplicateSemesterException extends RuntimeException {
public DuplicateSemesterException() {
super("Operation would result in semesters");
super("Operation would result in duplicate semesters");
}
}
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/AppParametersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void equals() {
assertEquals(appParameters, appParameters);

// null -> returns false
assertNotEquals(null, appParameters);
assertNotEquals(appParameters, null);

// different types -> returns false
assertNotEquals(appParameters, 0.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void equals() {
assertNotEquals(1, addCommand);

// null -> returns false
assertNotEquals(null, addCommand);
assertNotEquals(addCommand, null);

// different module code -> returns false
AddCommand differentCode = new AddCommand(otherModule.getModuleCode(), module.getYearTaken(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void equals() {
assertEquals(commandResult, commandResult);

// null -> returns false
assertNotEquals(null, commandResult);
assertNotEquals(commandResult, null);

// different types -> returns false
assertNotEquals(commandResult, 0.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void equals() {
assertNotEquals(1, deleteCommand);

// null -> returns false
assertNotEquals(null, deleteCommand);
assertNotEquals(deleteCommand, null);

// different module -> returns false
DeleteCommand differentDeleteCommand = prepareDeleteCommand(otherModule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void equals() {
assertEquals(standardCommand, standardCommand);

// null -> returns false
assertNotEquals(null, standardCommand);
assertNotEquals(standardCommand, null);

// different types -> returns false
assertNotEquals(standardCommand, new HelpCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void equals() {
assertEquals(DESC_CS2040S, DESC_CS2040S);

// null -> returns false
assertNotEquals(null, DESC_CS2040S);
assertNotEquals(DESC_CS2040S, null);

// different types -> returns false
assertNotEquals(5, DESC_CS2040S);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void equals() {
assertNotEquals(1, infoCommand);

// null -> returns false
assertNotEquals(null, infoCommand);
assertNotEquals(infoCommand, null);

// different module -> returns false
InfoCommand differentInfoCommand = prepareInfoCommand(otherModule);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void equals() {
assertEquals(modelManager, modelManager);

// null -> returns false
assertNotEquals(null, modelManager);
assertNotEquals(modelManager, null);

// different types -> returns false
assertNotEquals(5, modelManager);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/model/ModuleDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void equals() {
assertEquals(moduleData, moduleData);

// null -> returns false
assertNotEquals(null, moduleData);
assertNotEquals(moduleData, null);

// different types -> returns false
assertNotEquals(5, moduleData);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/model/module/ModuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void equals() {
assertEquals(CS2040S, CS2040S);

// null -> returns false
assertNotEquals(null, CS2040S);
assertNotEquals(CS2040S, null);

// different type -> returns false
assertNotEquals(5, CS2040S);
Expand Down
Loading

0 comments on commit d26e026

Please sign in to comment.