use of org.neo4j.graphdb.schema.ConstraintDefinition in project neo4j by neo4j.
the class SchemaWithPECAcceptanceTest method shouldListAddedConstraints.
@Test
public void shouldListAddedConstraints() throws Exception {
// GIVEN
ConstraintDefinition constraint1 = createUniquenessConstraint(label, propertyKey);
ConstraintDefinition constraint2 = createNodePropertyExistenceConstraint(label, propertyKey);
ConstraintDefinition constraint3 = createRelationshipPropertyExistenceConstraint(Types.MY_TYPE, propertyKey);
// WHEN THEN
assertThat(getConstraints(db), containsOnly(constraint1, constraint2, constraint3));
}
use of org.neo4j.graphdb.schema.ConstraintDefinition in project neo4j by neo4j.
the class SchemaWithPECAcceptanceTest method shouldCreateRelationshipPropertyExistenceConstraint.
@Test
public void shouldCreateRelationshipPropertyExistenceConstraint() {
// When
ConstraintDefinition constraint = createRelationshipPropertyExistenceConstraint(Types.MY_TYPE, propertyKey);
// Then
assertThat(getConstraints(db), containsOnly(constraint));
}
use of org.neo4j.graphdb.schema.ConstraintDefinition in project neo4j by neo4j.
the class SchemaWithPECAcceptanceTest method shouldListAddedConstraintsByLabel.
@Test
public void shouldListAddedConstraintsByLabel() throws Exception {
// GIVEN
ConstraintDefinition constraint1 = createUniquenessConstraint(label, propertyKey);
ConstraintDefinition constraint2 = createNodePropertyExistenceConstraint(label, propertyKey);
createNodePropertyExistenceConstraint(Labels.MY_OTHER_LABEL, propertyKey);
// WHEN THEN
assertThat(getConstraints(db, label), containsOnly(constraint1, constraint2));
}
use of org.neo4j.graphdb.schema.ConstraintDefinition in project neo4j by neo4j.
the class SchemaWithPECAcceptanceTest method shouldCreateNodePropertyExistenceConstraint.
@Test
public void shouldCreateNodePropertyExistenceConstraint() {
// When
ConstraintDefinition constraint = createNodePropertyExistenceConstraint(label, propertyKey);
// Then
assertThat(getConstraints(db), containsOnly(constraint));
}
use of org.neo4j.graphdb.schema.ConstraintDefinition in project neo4j by neo4j.
the class IndexConstraintsTest method convertConstraintToIndex.
@Test
public void convertConstraintToIndex() {
try (Transaction tx = graphDb.beginTx()) {
graphDb.schema().constraintFor(LABEL).assertPropertyIsUnique(PROPERTY_KEY).create();
tx.success();
}
try (Transaction tx = graphDb.beginTx()) {
ConstraintDefinition constraint = firstOrNull(graphDb.schema().getConstraints(LABEL));
constraint.drop();
graphDb.schema().indexFor(LABEL).on(PROPERTY_KEY).create();
tx.success();
}
// assert no exception is thrown
}
Aggregations