Skip to content

Commit

Permalink
MapCommandTest fully implemented + miscellaneous changes
Browse files Browse the repository at this point in the history
  • Loading branch information
articstranger committed Apr 13, 2019
1 parent a00208b commit 5197520
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 10 deletions.
Empty file added articstranger.png}
Empty file.
Binary file added docs/diagrams/MapSequenceDiagram.pptx
Binary file not shown.
Binary file added docs/images/MapSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Volunteerclasswithpoints.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added ndhuu.png}
Empty file.
Empty file added quinnzzzzz.png}
Empty file.
1 change: 0 additions & 1 deletion src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ public class Messages {
public static final String MESSAGE_INVALID_VOLUNTEER_DISPLAYED_INDEX = "The volunteer index provided is invalid";
public static final String MESSAGE_NOT_ENOUGH_VOLUNTEERS = "The volunteer pool does not have enough volunteers!";
public static final String MESSAGE_VOLUNTEERS_LISTED_OVERVIEW = "%1$d volunteers listed!";
public static final String MESSAGE_MAP_SUCCESS = "Mapping success!";
public static final String MESSAGE_INVALID_AGE_FORMAT = "Invalid year input!";
}
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/commands/MapCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import static java.util.Objects.requireNonNull;

import seedu.address.commons.core.Messages;
import seedu.address.logic.CommandHistory;
import seedu.address.model.MapObject;
import seedu.address.model.Model;
Expand Down Expand Up @@ -39,7 +38,7 @@ public CommandResult execute(Model model, CommandHistory history) {
requireNonNull(model);
model.mapAllVolunteer(map);
return new CommandResult(
String.format(Messages.MESSAGE_MAP_SUCCESS));
String.format(MESSAGE_SUCCESS));
}

}
61 changes: 61 additions & 0 deletions src/test/java/seedu/address/logic/commands/MapCommandTest.java
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);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

import org.junit.Rule;
Expand Down Expand Up @@ -403,6 +404,12 @@ public void mapAllVolunteer(MapObject map) {
public void sortVolunteers() {

}

@Override
public List<String[]> addData(int numVolunteers, ArrayList<String> prefixToBePrinted) {
throw new AssertionError("This method "
+ "should not be called.");
}
}

/**
Expand Down
34 changes: 27 additions & 7 deletions src/test/java/seedu/address/testutil/TypicalVolunteers.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 added swalahlah.png}
Empty file.

0 comments on commit 5197520

Please sign in to comment.