Search in sources :

Example 26 with Property

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

the class GraknTxPropertyTest method whenCallingGetResourcesByValueAfterAddingAResource_TheResultIncludesTheResource.

@Property
public void whenCallingGetResourcesByValueAfterAddingAResource_TheResultIncludesTheResource(@Open GraknTx graph, @FromTx @NonMeta @NonAbstract AttributeType attributeType, @From(ResourceValues.class) Object value) {
    assumeThat(value.getClass().getName(), is(attributeType.getDataType().getName()));
    Collection<Attribute<Object>> expectedAttributes = graph.getAttributesByValue(value);
    Attribute attribute = attributeType.putAttribute(value);
    Collection<Attribute<Object>> resourcesAfter = graph.getAttributesByValue(value);
    expectedAttributes.add(attribute);
    assertEquals(expectedAttributes, resourcesAfter);
}
Also used : Attribute(ai.grakn.concept.Attribute) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Property(com.pholser.junit.quickcheck.Property)

Example 27 with Property

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

the class GraknTxPropertyTest method whenSetRegexOnMetaResourceType_Throw.

// TODO: Everything below this point should be moved to more appropriate test classes
@Property
public void whenSetRegexOnMetaResourceType_Throw(@Open GraknTx graph, String regex) {
    AttributeType resource = graph.admin().getMetaAttributeType();
    exception.expect(GraknTxOperationException.class);
    exception.expectMessage(GraknTxOperationException.cannotSetRegex(resource).getMessage());
    resource.setRegex(regex);
}
Also used : AttributeType(ai.grakn.concept.AttributeType) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Property(com.pholser.junit.quickcheck.Property)

Example 28 with Property

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

the class GraknTxPropertyTest method whenCallingGetResourceType_TheResultIsTheSameAsGetSchemaConcept.

@Property
public void whenCallingGetResourceType_TheResultIsTheSameAsGetSchemaConcept(@Open GraknTx graph, @FromTx AttributeType type) {
    Label label = type.getLabel();
    assertSameResult(() -> graph.getSchemaConcept(label), () -> graph.getAttributeType(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 29 with Property

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

the class GraknTxPropertyTest method whenCallingGetConceptWithAnIncorrectGeneric_ItThrows.

@Property
public void whenCallingGetConceptWithAnIncorrectGeneric_ItThrows(@Open GraknTx graph, @FromTx Concept concept) {
    assumeFalse(concept.isRole());
    ConceptId id = concept.getId();
    exception.expect(ClassCastException.class);
    // We have to assign the result for the cast to happen
    // noinspection unused
    Role role = graph.getConcept(id);
}
Also used : Role(ai.grakn.concept.Role) ConceptId(ai.grakn.concept.ConceptId) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Property(com.pholser.junit.quickcheck.Property)

Example 30 with Property

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

the class RelationshipTypePropertyTest method whenRelatingARole_TheDirectSubTypeRelatedRolesAreUnchanged.

@Property
public void whenRelatingARole_TheDirectSubTypeRelatedRolesAreUnchanged(@NonMeta RelationshipType subType, @FromTx Role role) {
    RelationshipType superType = subType.sup();
    assumeFalse(isMetaLabel(superType.getLabel()));
    Set<Role> previousHasRoles = subType.relates().collect(toSet());
    superType.relates(role);
    Set<Role> newHasRoles = subType.relates().collect(toSet());
    assertEquals(previousHasRoles, newHasRoles);
}
Also used : Role(ai.grakn.concept.Role) RelationshipType(ai.grakn.concept.RelationshipType) Property(com.pholser.junit.quickcheck.Property)

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