use of ai.grakn.concept.Label in project grakn by graknlabs.
the class SchemaConceptTest method whenChangingTheLabelOfSchemaConceptAndThatLabelIsTakenByAnotherConcept_Throw.
@Test
public void whenChangingTheLabelOfSchemaConceptAndThatLabelIsTakenByAnotherConcept_Throw() {
Label label = Label.of("mylabel");
EntityType e1 = tx.putEntityType("Entity1");
tx.putEntityType(label);
expectedException.expect(GraknTxOperationException.class);
expectedException.expectMessage(ErrorMessage.LABEL_TAKEN.getMessage(label));
e1.setLabel(label);
}
use of ai.grakn.concept.Label in project grakn by graknlabs.
the class GrpcServerIT method whenDeletingAConcept_TheConceptIsDeleted.
@Test
public void whenDeletingAConcept_TheConceptIsDeleted() {
Label label = Label.of("hello");
try (GraknTx tx = localSession.open(GraknTxType.WRITE)) {
tx.putEntityType(label);
tx.commit();
}
try (GraknTx tx = remoteSession.open(GraknTxType.WRITE)) {
SchemaConcept schemaConcept = tx.getSchemaConcept(label);
assertFalse(schemaConcept.isDeleted());
schemaConcept.delete();
assertTrue(schemaConcept.isDeleted());
tx.commit();
}
try (GraknTx tx = localSession.open(GraknTxType.WRITE)) {
assertNull(tx.getSchemaConcept(label));
}
}
use of ai.grakn.concept.Label in project grakn by graknlabs.
the class Labels method generateFromTx.
@Override
public Label generateFromTx() {
if (mustBeUnused) {
Label label;
int attempts = 0;
do {
// After a certain number of attempts, generate truly random strings instead
if (attempts < 100) {
label = metaSyntacticLabel();
} else {
label = trueRandomLabel();
}
attempts += 1;
} while (tx().getSchemaConcept(label) != null);
return label;
} else {
return metaSyntacticLabel();
}
}
use of ai.grakn.concept.Label in project grakn by graknlabs.
the class HasAttributePropertyTest method whenCallingCheckValidPropertyAndLabelRefersToARole_Throw.
@Test
public void whenCallingCheckValidPropertyAndLabelRefersToARole_Throw() {
Label label = Schema.MetaSchema.ROLE.getLabel();
HasAttributeProperty property = HasAttributeProperty.of(label, var("x").admin(), var().admin());
exception.expect(GraqlQueryException.class);
exception.expectMessage(GraqlQueryException.mustBeAttributeType(label).getMessage());
property.checkValidProperty(sampleKB.tx(), var("y").admin());
}
use of ai.grakn.concept.Label in project grakn by graknlabs.
the class AdminTest method testGetTypesInQuery.
@Test
public void testGetTypesInQuery() {
Match match = qb.match(var("x").isa(label("movie").sub("production")).has("tmdb-vote-count", 400), var("y").isa("character"), var().rel("production-with-cast", "x").rel("y").isa("has-cast"));
Set<SchemaConcept> types = Stream.of("movie", "production", "tmdb-vote-count", "character", "production-with-cast", "has-cast").map(t -> rule.tx().<SchemaConcept>getSchemaConcept(Label.of(t))).collect(toSet());
assertEquals(types, match.admin().getSchemaConcepts());
}
Aggregations