use of ai.grakn.kb.internal.concept.ThingImpl in project grakn by graknlabs.
the class ValidateGlobalRulesTest method testValidatePlaysStructure.
@Test
public void testValidatePlaysStructure() throws Exception {
EntityTypeImpl wolf = (EntityTypeImpl) tx.putEntityType("wolf");
EntityTypeImpl creature = (EntityTypeImpl) tx.putEntityType("creature");
EntityTypeImpl hunter = (EntityTypeImpl) tx.putEntityType("hunter");
RelationshipType hunts = tx.putRelationshipType("hunts");
RoleImpl witcher = (RoleImpl) tx.putRole("witcher");
RoleImpl monster = (RoleImpl) tx.putRole("monster");
Thing geralt = hunter.addEntity();
ThingImpl werewolf = (ThingImpl) wolf.addEntity();
RelationshipImpl assertion = (RelationshipImpl) hunts.addRelationship().addRolePlayer(witcher, geralt).addRolePlayer(monster, werewolf);
assertion.reified().get().castingsRelation().forEach(rolePlayer -> assertFalse(ValidateGlobalRules.validatePlaysAndRelatesStructure(rolePlayer).isEmpty()));
hunter.plays(witcher);
boolean[] flags = { false, false };
int count = 0;
for (Casting casting : assertion.reified().get().castingsRelation().collect(Collectors.toSet())) {
flags[count] = !ValidateGlobalRules.validatePlaysAndRelatesStructure(casting).isEmpty();
count++;
}
assertTrue(flags[0] && flags[1]);
wolf.sup(creature);
creature.plays(monster);
for (Casting casting : assertion.reified().get().castingsRelation().collect(Collectors.toSet())) {
assertFalse(ValidateGlobalRules.validatePlaysAndRelatesStructure(casting).isEmpty());
}
}
Aggregations