Search in sources :

Example 46 with Property

use of com.pholser.junit.quickcheck.Property in project grakn by graknlabs.

the class GraknTxPropertyTest method whenCallingSuperTypeOnMetaResourceType_Throw.

// TODO: Fix this
@Ignore
@Property
public void whenCallingSuperTypeOnMetaResourceType_Throw(@Open GraknTx graph) {
    AttributeType resource = graph.admin().getMetaAttributeType();
    // TODO: Test for a better error message
    exception.expect(GraknTxOperationException.class);
    // noinspection ResultOfMethodCallIgnored
    resource.sup();
}
Also used : AttributeType(ai.grakn.concept.AttributeType) Ignore(org.junit.Ignore) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Property(com.pholser.junit.quickcheck.Property)

Example 47 with Property

use of com.pholser.junit.quickcheck.Property in project grakn by graknlabs.

the class GraknTxPropertyTest method whenCallingGetRelationType_TheResultIsTheSameAsGetSchemaConcept.

@Property
public void whenCallingGetRelationType_TheResultIsTheSameAsGetSchemaConcept(@Open GraknTx graph, @FromTx RelationshipType type) {
    Label label = type.getLabel();
    assertSameResult(() -> graph.getSchemaConcept(label), () -> graph.getRelationshipType(label.getValue()));
}
Also used : Label(ai.grakn.concept.Label) MetaSchema.isMetaLabel(ai.grakn.util.Schema.MetaSchema.isMetaLabel) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Property(com.pholser.junit.quickcheck.Property)

Example 48 with Property

use of com.pholser.junit.quickcheck.Property in project grakn by graknlabs.

the class SchemaConceptPropertyTest method whenAddingADirectSubWhichIsAnIndirectSuper_Throw.

// TODO
@Ignore("Test fails due to incorrect error message")
@Property
public void whenAddingADirectSubWhichIsAnIndirectSuper_Throw(@NonMeta SchemaConcept newSubConcept, long seed) {
    SchemaConcept concept = PropertyUtil.choose(newSubConcept.subs(), seed);
    // Check if the mutation can be performed in a valid manner
    if (concept.isType())
        assumeThat(concept.asType().plays().collect(Collectors.toSet()), is(empty()));
    exception.expect(GraknTxOperationException.class);
    exception.expectMessage(GraknTxOperationException.loopCreated(newSubConcept, concept).getMessage());
    addDirectSub(concept, newSubConcept);
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) Ignore(org.junit.Ignore) Property(com.pholser.junit.quickcheck.Property)

Example 49 with Property

use of com.pholser.junit.quickcheck.Property in project grakn by graknlabs.

the class TypePropertyTest method whenAddingAPlaysToATypesIndirectSuperType_TheTypePlaysThatRole.

@Property
public void whenAddingAPlaysToATypesIndirectSuperType_TheTypePlaysThatRole(@Open GraknTx tx, @FromTx Type type, @FromTx Role role, long seed) {
    SchemaConcept superConcept = PropertyUtil.choose(tx.admin().sups(type), seed);
    assumeTrue(superConcept.isType());
    assumeFalse(isMetaLabel(superConcept.getLabel()));
    Type superType = superConcept.asType();
    Set<Role> previousPlays = type.plays().collect(toSet());
    superType.plays(role);
    Set<Role> newPlays = type.plays().collect(toSet());
    assertEquals(newPlays, Sets.union(previousPlays, ImmutableSet.of(role)));
}
Also used : Role(ai.grakn.concept.Role) Type(ai.grakn.concept.Type) AttributeType(ai.grakn.concept.AttributeType) SchemaConcept(ai.grakn.concept.SchemaConcept) Property(com.pholser.junit.quickcheck.Property)

Example 50 with Property

use of com.pholser.junit.quickcheck.Property in project grakn by graknlabs.

the class EntityTypePropertyTest method whenAddingAnEntity_TheDirectTypeOfTheEntityIsTheTypeItWasCreatedFrom.

@Property
public void whenAddingAnEntity_TheDirectTypeOfTheEntityIsTheTypeItWasCreatedFrom(@NonMeta @NonAbstract EntityType type) {
    Entity entity = type.addEntity();
    assertEquals(type, entity.type());
}
Also used : Entity(ai.grakn.concept.Entity) Property(com.pholser.junit.quickcheck.Property)

Aggregations

Property (com.pholser.junit.quickcheck.Property)59 Matchers.hasProperty (org.hamcrest.Matchers.hasProperty)15 Role (ai.grakn.concept.Role)11 Label (ai.grakn.concept.Label)10 MetaSchema.isMetaLabel (ai.grakn.util.Schema.MetaSchema.isMetaLabel)10 SchemaConcept (ai.grakn.concept.SchemaConcept)9 RelationshipType (ai.grakn.concept.RelationshipType)8 AttributeType (ai.grakn.concept.AttributeType)7 VarProperty (ai.grakn.graql.admin.VarProperty)5 Ignore (org.junit.Ignore)5 Relationship (ai.grakn.concept.Relationship)4 ConceptId (ai.grakn.concept.ConceptId)3 Entity (ai.grakn.concept.Entity)3 EntityType (ai.grakn.concept.EntityType)3 Type (ai.grakn.concept.Type)3 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)3 Rule (ai.grakn.concept.Rule)2 Pattern (ai.grakn.graql.Pattern)2 VarPattern (ai.grakn.graql.VarPattern)2 Attribute (ai.grakn.concept.Attribute)1