Search in sources :

Example 6 with SchemaConcept

use of ai.grakn.concept.SchemaConcept in project grakn by graknlabs.

the class SchemaConceptPropertyTest method whenASchemaConceptHasAnIndirectSub_ItIsAnIndirectSuperOfThatSub.

@Property
public void whenASchemaConceptHasAnIndirectSub_ItIsAnIndirectSuperOfThatSub(@Open GraknTx tx, @FromTx SchemaConcept superConcept, long seed) {
    SchemaConcept subConcept = PropertyUtil.choose(superConcept.subs(), seed);
    assertThat(tx.admin().sups(subConcept).collect(toSet()), hasItem(superConcept));
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) Property(com.pholser.junit.quickcheck.Property)

Example 7 with SchemaConcept

use of ai.grakn.concept.SchemaConcept in project grakn by graknlabs.

the class GraknTxPutPropertyTest method whenCallingAnyPutSchemaConceptMethod_CreateAnOntologyConceptWithDefaultProperties.

@Property
public void whenCallingAnyPutSchemaConceptMethod_CreateAnOntologyConceptWithDefaultProperties(@Open GraknTx graph, @Unused Label label, @From(PutSchemaConceptFunctions.class) BiFunction<GraknTx, Label, SchemaConcept> putSchemaConcept) {
    SchemaConcept concept = putSchemaConcept.apply(graph, label);
    assertThat("Concept should only have one sub-type: itself", concept.subs().collect(toSet()), contains(concept));
    assertFalse("Concept should not be implicit", concept.isImplicit());
    assertThat("Rules of hypotheses should be empty", concept.getRulesOfHypothesis().collect(toSet()), empty());
    assertThat("Rules of conclusion should be empty", concept.getRulesOfConclusion().collect(toSet()), empty());
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) Property(com.pholser.junit.quickcheck.Property)

Example 8 with SchemaConcept

use of ai.grakn.concept.SchemaConcept in project grakn by graknlabs.

the class GraknTxPutPropertyTest method whenCallingAnyPutSchemaConceptMethod_CreateAnOntologyConceptWithTheGivenLabel.

@Property
public void whenCallingAnyPutSchemaConceptMethod_CreateAnOntologyConceptWithTheGivenLabel(@Open GraknTx graph, @Unused Label label, @From(PutSchemaConceptFunctions.class) BiFunction<GraknTx, Label, SchemaConcept> putSchemaConcept) {
    SchemaConcept type = putSchemaConcept.apply(graph, label);
    assertEquals(label, type.getLabel());
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) Property(com.pholser.junit.quickcheck.Property)

Example 9 with SchemaConcept

use of ai.grakn.concept.SchemaConcept in project grakn by graknlabs.

the class SchemaConceptPropertyTest method whenDeletingASchemaConceptWithDirectSubs_Throw.

@Property
public void whenDeletingASchemaConceptWithDirectSubs_Throw(@NonMeta SchemaConcept schemaConcept) {
    SchemaConcept superConcept = schemaConcept.sup();
    assumeFalse(isMetaLabel(superConcept.getLabel()));
    exception.expect(GraknTxOperationException.class);
    exception.expectMessage(GraknTxOperationException.cannotBeDeleted(superConcept).getMessage());
    superConcept.delete();
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) Property(com.pholser.junit.quickcheck.Property)

Example 10 with SchemaConcept

use of ai.grakn.concept.SchemaConcept in project grakn by graknlabs.

the class SchemaConceptPropertyTest method whenASchemaConceptHasAnIndirectSuper_ItIsAnIndirectSubOfThatSuper.

@Property
public void whenASchemaConceptHasAnIndirectSuper_ItIsAnIndirectSubOfThatSuper(@Open GraknTx tx, @FromTx SchemaConcept subConcept, long seed) {
    SchemaConcept superConcept = PropertyUtil.choose(tx.admin().sups(subConcept), seed);
    assertThat(superConcept.subs().collect(toSet()), hasItem(subConcept));
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) Property(com.pholser.junit.quickcheck.Property)

Aggregations

SchemaConcept (ai.grakn.concept.SchemaConcept)51 Label (ai.grakn.concept.Label)19 Set (java.util.Set)15 Type (ai.grakn.concept.Type)14 GraknTx (ai.grakn.GraknTx)12 HashSet (java.util.HashSet)12 ConceptId (ai.grakn.concept.ConceptId)11 Stream (java.util.stream.Stream)11 Test (org.junit.Test)11 AttributeType (ai.grakn.concept.AttributeType)10 Property (com.pholser.junit.quickcheck.Property)10 Role (ai.grakn.concept.Role)9 Concept (ai.grakn.concept.Concept)8 Sets (com.google.common.collect.Sets)8 Optional (java.util.Optional)8 RelationshipType (ai.grakn.concept.RelationshipType)7 Rule (ai.grakn.concept.Rule)7 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)7 ErrorMessage (ai.grakn.util.ErrorMessage)7 Var (ai.grakn.graql.Var)6