Search in sources :

Example 11 with Property

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

the class GraknTxPutPropertyTest method whenCallingPutEntityTypeWithAnExistingEntityTypeLabel_ItReturnsThatType.

@Property
public void whenCallingPutEntityTypeWithAnExistingEntityTypeLabel_ItReturnsThatType(@Open GraknTx graph, @FromTx EntityType entityType) {
    EntityType newType = graph.putEntityType(entityType.getLabel());
    assertEquals(entityType, newType);
}
Also used : EntityType(ai.grakn.concept.EntityType) Property(com.pholser.junit.quickcheck.Property)

Example 12 with Property

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

the class GraknTxPutPropertyTest method whenCallingPutResourceTypeWithAnExistingNonUniqueResourceTypeLabelButADifferentDataType_Throw.

@Property
public void whenCallingPutResourceTypeWithAnExistingNonUniqueResourceTypeLabelButADifferentDataType_Throw(@Open GraknTx graph, @FromTx AttributeType<?> attributeType, AttributeType.DataType<?> dataType) {
    assumeThat(dataType, not(is(attributeType.getDataType())));
    Label label = attributeType.getLabel();
    exception.expect(GraknTxOperationException.class);
    if (isMetaLabel(label)) {
        exception.expectMessage(GraknTxOperationException.metaTypeImmutable(label).getMessage());
    } else {
        exception.expectMessage(GraknTxOperationException.immutableProperty(attributeType.getDataType(), dataType, Schema.VertexProperty.DATA_TYPE).getMessage());
    }
    graph.putAttributeType(label, dataType);
}
Also used : MetaSchema.isMetaLabel(ai.grakn.util.Schema.MetaSchema.isMetaLabel) Label(ai.grakn.concept.Label) Property(com.pholser.junit.quickcheck.Property)

Example 13 with Property

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

the class GraknTxPutPropertyTest method whenCallingPutRuleWithAnExistingRuleTypeLabel_ItReturnsThatType.

@Property
public void whenCallingPutRuleWithAnExistingRuleTypeLabel_ItReturnsThatType(@Open GraknTx tx, @FromTx Rule rule) {
    Rule newType = tx.putRule(rule.getLabel(), tx.graql().parser().parsePattern("$x"), tx.graql().parser().parsePattern("$x"));
    assertEquals(rule, newType);
}
Also used : Rule(ai.grakn.concept.Rule) Property(com.pholser.junit.quickcheck.Property)

Example 14 with Property

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

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

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