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