use of ai.grakn.concept.Type in project grakn by graknlabs.
the class EntityTypeTest method whenGettingTheLabelOfType_TheTypeLabelIsReturned.
@Test
public void whenGettingTheLabelOfType_TheTypeLabelIsReturned() {
Type test = tx.putEntityType("test");
assertEquals(Label.of("test"), test.getLabel());
}
use of ai.grakn.concept.Type in project grakn by graknlabs.
the class EntityTypeTest method whenAddingRoleToMetaType_Throw.
@Test
public void whenAddingRoleToMetaType_Throw() {
Type meta = tx.getMetaEntityType();
Role role = tx.putRole("A Role");
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(GraknTxOperationException.metaTypeImmutable(meta.getLabel()).getMessage());
meta.plays(role);
}
use of ai.grakn.concept.Type in project grakn by graknlabs.
the class EntityTypeTest method whenGettingTheSuperSetViaSupsMethod_ReturnAllOfItsSuperTypes.
@Test
public void whenGettingTheSuperSetViaSupsMethod_ReturnAllOfItsSuperTypes() {
EntityType child = tx.putEntityType("child");
EntityType p2 = tx.putEntityType("p2").sub(child);
EntityType p3 = tx.putEntityType("p3").sub(p2);
EntityType p4 = tx.putEntityType("p4").sub(p3);
EntityType entity = tx.getMetaEntityType();
Type thing = tx.getMetaConcept();
assertThat(child.sups().collect(toSet()), containsInAnyOrder(child, p2, p3, p4, entity));
assertThat(p2.sups().collect(toSet()), containsInAnyOrder(p2, p3, p4, entity));
assertThat(p3.sups().collect(toSet()), containsInAnyOrder(p3, p4, entity));
assertThat(p4.sups().collect(toSet()), containsInAnyOrder(p4, entity));
assertThat(entity.sups().collect(toSet()), containsInAnyOrder(entity));
assertThat(thing.sups().collect(toSet()), empty());
}
use of ai.grakn.concept.Type in project grakn by graknlabs.
the class GraknMatchers method getTypes.
private static Set<Type> getTypes(Thing thing) {
Set<Type> types = Sets.newHashSet();
Type type = thing.type();
while (type != null) {
types.add(type);
type = type.sup();
}
return types;
}
use of ai.grakn.concept.Type in project grakn by graknlabs.
the class GrpcServerIT method whenGettingAType_TheInformationOnTheTypeIsCorrect.
@Test
public void whenGettingAType_TheInformationOnTheTypeIsCorrect() {
try (GraknTx remoteTx = remoteSession.open(GraknTxType.READ);
GraknTx localTx = localSession.open(GraknTxType.READ)) {
GetQuery query = remoteTx.graql().match(var("x").label("person")).get();
Type remoteConcept = query.stream().findAny().get().get("x").asType();
Type localConcept = localTx.getConcept(remoteConcept.getId()).asType();
assertEquals(localConcept.isAbstract(), remoteConcept.isAbstract());
assertEqualConcepts(localConcept, remoteConcept, Type::plays);
assertEqualConcepts(localConcept, remoteConcept, Type::instances);
assertEqualConcepts(localConcept, remoteConcept, Type::attributes);
assertEqualConcepts(localConcept, remoteConcept, Type::keys);
}
}
Aggregations