Search in sources :

Example 16 with Property

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

the class SchemaConceptPropertyTest method whenCallingGetLabel_TheResultCanBeUsedToRetrieveTheSameConcept.

@Property
public void whenCallingGetLabel_TheResultCanBeUsedToRetrieveTheSameConcept(@Open GraknTx graph, @FromTx SchemaConcept concept) {
    Label label = concept.getLabel();
    assertEquals(concept, graph.getSchemaConcept(label));
}
Also used : MetaSchema.isMetaLabel(ai.grakn.util.Schema.MetaSchema.isMetaLabel) Label(ai.grakn.concept.Label) Property(com.pholser.junit.quickcheck.Property)

Example 17 with Property

use of com.pholser.junit.quickcheck.Property 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)

Example 18 with Property

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

the class SchemaConceptPropertyTest method whenSettingTheDirectSuperToAnIndirectSub_Throw.

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

Example 19 with Property

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

the class DefineQueryPropertyTest method aDefineQueryWithoutASubOrPlaysOrRelatesProperty_CannotBeInserted.

@Ignore("Currently no error message is returned when trying to insert an empty set of propoerties. I am not entirely sure this is correct")
@Property
public void aDefineQueryWithoutASubOrPlaysOrRelatesProperty_CannotBeInserted(@Open GraknTx tx, @Size(max = 5) Set<VarProperty> properties) {
    boolean containsSub = properties.stream().anyMatch(SubProperty.class::isInstance);
    boolean containsPlays = properties.stream().anyMatch(PlaysProperty.class::isInstance);
    boolean containsRelates = properties.stream().anyMatch(RelatesProperty.class::isInstance);
    assumeFalse(containsSub || containsPlays || containsRelates);
    VarPatternAdmin pattern = Patterns.varPattern(Graql.var("x"), properties);
    exception.expect(GraqlQueryException.class);
    tx.graql().define(pattern).execute();
}
Also used : RelatesProperty(ai.grakn.graql.internal.pattern.property.RelatesProperty) SubProperty(ai.grakn.graql.internal.pattern.property.SubProperty) VarPatternAdmin(ai.grakn.graql.admin.VarPatternAdmin) PlaysProperty(ai.grakn.graql.internal.pattern.property.PlaysProperty) Ignore(org.junit.Ignore) Property(com.pholser.junit.quickcheck.Property) SubProperty(ai.grakn.graql.internal.pattern.property.SubProperty) VarProperty(ai.grakn.graql.admin.VarProperty) PlaysProperty(ai.grakn.graql.internal.pattern.property.PlaysProperty) RelatesProperty(ai.grakn.graql.internal.pattern.property.RelatesProperty)

Example 20 with Property

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

the class PatternPropertyTests method theDisjunctionOfTwoPatterns_ShouldBeContainedInTheResultingPattern.

@Property
public void theDisjunctionOfTwoPatterns_ShouldBeContainedInTheResultingPattern(Pattern pattern1, Pattern pattern2) {
    Set<VarPattern> union = Sets.union(pattern1.admin().varPatterns(), pattern2.admin().varPatterns());
    Pattern disjunction = pattern1.or(pattern2);
    assertEquals(union, disjunction.admin().varPatterns());
}
Also used : VarPattern(ai.grakn.graql.VarPattern) Pattern(ai.grakn.graql.Pattern) VarPattern(ai.grakn.graql.VarPattern) Property(com.pholser.junit.quickcheck.Property) VarProperty(ai.grakn.graql.admin.VarProperty)

Aggregations

Property (com.pholser.junit.quickcheck.Property)82 Matchers.hasProperty (org.hamcrest.Matchers.hasProperty)15 Program (com.rox.emu.processor.mos6502.util.Program)12 Role (ai.grakn.concept.Role)11 Label (ai.grakn.concept.Label)10 MetaSchema.isMetaLabel (ai.grakn.util.Schema.MetaSchema.isMetaLabel)10 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)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 Calendar (java.util.Calendar)4 Schema (org.apache.beam.sdk.schemas.Schema)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