use of won.utils.goals.GoalInstantiationResult in project webofneeds by researchstudio-sat.
the class GoalInstantiationTest method example4_geoCoordinatesFulfilled.
@Test
public void example4_geoCoordinatesFulfilled() throws IOException {
Dataset need1 = loadDataset(baseFolder + "ex4_need.trig");
Dataset need2 = loadDataset(baseFolder + "ex4_need_debug.trig");
Dataset conversation = loadDataset(baseFolder + "ex4_conversation.trig");
GoalInstantiationProducer goalInstantiation = new GoalInstantiationProducer(need1, need2, conversation, "http://example.org/", "http://example.org/blended/");
Collection<GoalInstantiationResult> results = goalInstantiation.createAllGoalCombinationInstantiationResults();
// We have only one goal on each side so we expect only one result
Assert.assertEquals(1, results.size());
// We expect also one valid result
Collection<Model> validResults = new LinkedList<>();
for (GoalInstantiationResult result : results) {
if (result.isConform()) {
validResults.add(result.getInstanceModel());
}
}
Assert.assertEquals(1, validResults.size());
for (Model valid : validResults) {
valid.write(System.out, "TRIG");
}
}
use of won.utils.goals.GoalInstantiationResult in project webofneeds by researchstudio-sat.
the class GoalInstantiationTest method exampleTaxiFakeLocation_validity.
@Test
public void exampleTaxiFakeLocation_validity() throws IOException {
Dataset taxiOffer = loadDataset(baseFolder + "ex7_taxioffer.trig");
Dataset taxiDemand = loadDataset(baseFolder + "ex7_taxi.trig");
GoalInstantiationProducer goalInstantiation = new GoalInstantiationProducer(taxiOffer, taxiDemand, null, "http://example.org/", "http://example.org/blended/");
Collection<GoalInstantiationResult> results = goalInstantiation.createGoalInstantiationResultsForNeed1();
for (GoalInstantiationResult res : results) {
res.getInstanceModel().write(System.out, "TRIG");
Assert.assertTrue(res.isConform());
Coordinate departureAddress = getAddress(loadSparqlQuery("/won/utils/goals/extraction/address/northWestCornerQuery.rq"), res.getInstanceModel());
Coordinate destinationAddress = getAddress(loadSparqlQuery("/won/utils/goals/extraction/address/southEastCornerQuery.rq"), res.getInstanceModel());
Assert.assertEquals(departureAddress, new Coordinate(48.218727f, 16.360141f));
Assert.assertEquals(destinationAddress, new Coordinate(48.218828f, 16.360241f));
}
NeedModelWrapper needWrapper1 = new NeedModelWrapper(taxiOffer);
Resource goal = needWrapper1.getGoals().iterator().next();
GoalInstantiationResult result = goalInstantiation.findInstantiationForGoal(goal);
Assert.assertTrue(result.isConform());
GoalInstantiationResult recheckResultModel = GoalInstantiationProducer.findInstantiationForGoalInDataset(taxiOffer, goal, result.getInstanceModel());
Assert.assertTrue(recheckResultModel.isConform());
}
Aggregations