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));
}
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));
}
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);
}
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();
}
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());
}
Aggregations