forked from AY2425S1-CS2103T-T11-2/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request AY2425S1-CS2103T-T11-2#93 from currynia/branch-add…
…-AssignmentDatabase Add sample assignment data if file not found
- Loading branch information
Showing
5 changed files
with
78 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/seedu/address/model/util/SampleAssignmentsUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package seedu.address.model.util; | ||
|
||
import seedu.address.model.assignment.PredefinedAssignment; | ||
import seedu.address.model.assignment.PredefinedAssignmentsData; | ||
import seedu.address.model.assignment.ReadOnlyPredefinedAssignmentsData; | ||
|
||
/** | ||
* Contains utility methods for populating | ||
* {@code PredefinedAssignmentsData} with sample data. | ||
*/ | ||
public class SampleAssignmentsUtil { | ||
public static PredefinedAssignment[] getSampleAssignments() { | ||
return new PredefinedAssignment[]{ | ||
new PredefinedAssignment("Ex01", 10f), | ||
new PredefinedAssignment("Ex02", 10f), | ||
new PredefinedAssignment("Ex03", 25f) | ||
}; | ||
} | ||
|
||
/** | ||
* Returns predefined assignments database populated with the sample assignments. | ||
* | ||
* @return The sample predefined assignment database. | ||
*/ | ||
public static ReadOnlyPredefinedAssignmentsData getSamplePredefinedAssignments() { | ||
PredefinedAssignmentsData samplePredefinedAssignment = | ||
new PredefinedAssignmentsData(); | ||
for (PredefinedAssignment sample : getSampleAssignments()) { | ||
samplePredefinedAssignment.add(sample); | ||
} | ||
return samplePredefinedAssignment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/test/java/seedu/address/model/assignment/PredefinedAssignmentsDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package seedu.address.model.assignment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
|
||
class PredefinedAssignmentsDataTest { | ||
|
||
@Test | ||
public void addTest() { | ||
PredefinedAssignment sample = new PredefinedAssignment("Ex01", 0f); | ||
PredefinedAssignmentsData data = new PredefinedAssignmentsData(); | ||
ArrayList<PredefinedAssignment> expected = new ArrayList<>(List.of(sample)); | ||
assertEquals(data.add(sample), expected); | ||
} | ||
} |