better toString for actions and some more tests.

This commit is contained in:
Naveen Sundar Govindarajulu 2017-01-15 09:10:48 -05:00
parent 8c78a2f8e5
commit 598f9b3dff
10 changed files with 307 additions and 44 deletions

View file

@ -10,6 +10,7 @@ import org.testng.annotations.Test;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import static org.testng.Assert.*;
@ -33,7 +34,7 @@ public class DepthFirstPlannerTest {
Planner depthFirstPlanner = new DepthFirstPlanner();
PlanningProblem planningProblem = planningProblemList.get(2);
System.out.println(depthFirstPlanner.plan(planningProblem.background, planningProblem.actions, planningProblem.start, planningProblem.goal));
System.out.println(depthFirstPlanner.plan(planningProblem.getBackground(), planningProblem.getActions(), planningProblem.getStart(), planningProblem.getGoal()));
}
@DataProvider
@ -55,16 +56,29 @@ public class DepthFirstPlannerTest {
}
@Test(dataProvider = "testCompletenessDataProvider")
public void testCompletness(PlanningProblem planningProblem) throws Exception {
Optional<Set<Plan>> possiblePlans = depthFirstPlanner.plan(
planningProblem.background,
planningProblem.actions,
planningProblem.start,
planningProblem.goal);
planningProblem.getBackground(),
planningProblem.getActions(),
planningProblem.getStart(),
planningProblem.getGoal());
Assert.assertTrue(possiblePlans.isPresent());
Set<Plan> plans = possiblePlans.get();
if(planningProblem.getExpectedActionSequencesOpt().isPresent()){
Set<List<Action>> actionSequences = plans.stream().map(Plan::getActions).collect(Collectors.toSet());
Set<List<Action>> expectedActionSequences = planningProblem.getExpectedActionSequencesOpt().get();
Assert.assertEquals(actionSequences, expectedActionSequences);
}
}
}