forked from nusCS2113-AY1819S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MapCommandTest fully implemented + miscellaneous changes
- Loading branch information
1 parent
a00208b
commit 5197520
Showing
12 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
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
61 changes: 61 additions & 0 deletions
61
src/test/java/seedu/address/logic/commands/MapCommandTest.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 |
---|---|---|
@@ -1,4 +1,65 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.testutil.TypicalVolunteers.getTypicalAddressBook; | ||
import static seedu.address.testutil.TypicalVolunteers.getTypicalVolunteersPoints; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.ArrayList; | ||
import javafx.util.Pair; | ||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.model.MapObject; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
public class MapCommandTest { | ||
|
||
private CommandHistory commandHistory = new CommandHistory(); | ||
|
||
@Test | ||
public void test_emptyAddressBook_success() { | ||
Model model = new ModelManager(); | ||
Model expectedModel = new ModelManager(); | ||
CommandResult result = new MapCommand(defaultMap()).execute(model, commandHistory); | ||
assertEquals(model, expectedModel); | ||
} | ||
|
||
@Test | ||
public void test_nonEmptyAddressBook_success() { | ||
Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
new MapCommand(defaultMap()).execute(model, commandHistory); | ||
ArrayList<Integer> expectedPoints = getTypicalVolunteersPoints(); | ||
assertEquals(collectPoints(model), expectedPoints); | ||
} | ||
|
||
/** | ||
* | ||
* Goes through the @param model and collects points from all volunteers | ||
* @return points as an arraylist | ||
*/ | ||
public ArrayList<Integer> collectPoints(Model model) { | ||
ArrayList<Integer> points = new ArrayList<>(); | ||
model.getFilteredVolunteerList().forEach(vol -> { | ||
points.add(vol.getPoints()); | ||
}); | ||
return points; | ||
} | ||
|
||
/** | ||
* default mapobject stub | ||
* @return | ||
*/ | ||
private MapObject defaultMap(){ | ||
Pair<Integer, Integer> agePair = new Pair<>(2, 18); | ||
Pair<Integer, String> racePair = new Pair<>(1, "Chinese"); | ||
Pair<Integer, String> medicalPair = new Pair<>(3, "Nil"); | ||
String comparator = ">"; | ||
|
||
return new MapObject(agePair, comparator, racePair, medicalPair); | ||
} | ||
|
||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,22 +25,27 @@ public class TypicalVolunteers { | |
|
||
public static final Volunteer ALICE = new VolunteerBuilder().withName("Alice Pauline") | ||
.withAddress("123, Jurong West Ave 6, #08-111").withEmail("[email protected]") | ||
.withPhone("94351253") | ||
.withPhone("94351253").withAge("19").withRace("Chinese").withMedicalCondition("nil") | ||
.withTags("friends").build(); | ||
public static final Volunteer BENSON = new VolunteerBuilder().withName("Benson Meier") | ||
.withAddress("311, Clementi Ave 2, #02-25") | ||
.withAddress("311, Clementi Ave 2, #02-25").withAge("17").withRace("Chinese").withMedicalCondition("injured") | ||
.withEmail("[email protected]").withPhone("98765432") | ||
.withTags("owesMoney", "friends").build(); | ||
public static final Volunteer CARL = new VolunteerBuilder().withName("Carl Kurz").withPhone("95352563") | ||
.withEmail("[email protected]").withAddress("wall street").build(); | ||
.withEmail("[email protected]").withAddress("wall street") | ||
.withAge("19").withRace("French").withMedicalCondition("nil").build(); | ||
public static final Volunteer DANIEL = new VolunteerBuilder().withName("Daniel Meier").withPhone("87652533") | ||
.withEmail("[email protected]").withAddress("10th street").withTags("friends").build(); | ||
.withEmail("[email protected]").withAddress("10th street").withTags("friends") | ||
.withAge("19").withRace("Chinese").withMedicalCondition("nil").build(); | ||
public static final Volunteer ELLE = new VolunteerBuilder().withName("Elle Meyer").withPhone("9482224") | ||
.withEmail("[email protected]").withAddress("michegan ave").build(); | ||
.withEmail("[email protected]").withAddress("michegan ave") | ||
.withAge("29").withRace("Indian").withMedicalCondition("vegetable").build(); | ||
public static final Volunteer FIONA = new VolunteerBuilder().withName("Fiona Kunz").withPhone("9482427") | ||
.withEmail("[email protected]").withAddress("little tokyo").build(); | ||
.withEmail("[email protected]").withAddress("little tokyo") | ||
.withAge("13").withRace("English").withMedicalCondition("nil").build(); | ||
public static final Volunteer GEORGE = new VolunteerBuilder().withName("George Best").withPhone("9482442") | ||
.withEmail("[email protected]").withAddress("4th street").build(); | ||
.withEmail("[email protected]").withAddress("4th street") | ||
.withAge("15").withRace("Chinese").withMedicalCondition("dead").build(); | ||
|
||
// Manually added | ||
public static final Volunteer HOON = new VolunteerBuilder().withName("Hoon Meier").withPhone("8482424") | ||
|
@@ -74,4 +79,19 @@ public static AddressBook getTypicalAddressBook() { | |
public static List<Volunteer> getTypicalVolunteers() { | ||
return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); | ||
} | ||
|
||
|
||
|
||
public static ArrayList<Integer> getTypicalVolunteersPoints() { | ||
ArrayList<Integer> points = new ArrayList<>(); | ||
points.add(6); | ||
points.add(1); | ||
points.add(5); | ||
points.add(6); | ||
points.add(2); | ||
points.add(3); | ||
points.add(1); | ||
return points; | ||
} | ||
|
||
} |
Empty file.