use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class AbstractConstraintCreationIT method shouldNotPersistConstraintCreatedInAbortedTransaction.
@Test
public void shouldNotPersistConstraintCreatedInAbortedTransaction() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
createConstraint(schemaWriteOperations, descriptor);
// when
rollback();
ReadOperations readOperations = readOperationsInNewTransaction();
// then
Iterator<?> constraints = readOperations.constraintsGetAll();
assertFalse("should not have any constraints", constraints.hasNext());
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class NodePropertyExistenceConstraintCreationIT method shouldNotDropPropertyExistenceConstraintThatDoesNotExistWhenThereIsAUniquePropertyConstraint.
@Test
public void shouldNotDropPropertyExistenceConstraintThatDoesNotExistWhenThereIsAUniquePropertyConstraint() throws Exception {
// given
UniquenessConstraintDescriptor constraint;
{
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
constraint = statement.uniquePropertyConstraintCreate(descriptor);
commit();
}
// when
try {
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.constraintDrop(ConstraintDescriptorFactory.existsForSchema(constraint.schema()));
fail("expected exception");
}// then
catch (DropConstraintFailureException e) {
assertThat(e.getCause(), instanceOf(NoSuchConstraintException.class));
} finally {
rollback();
}
// then
{
ReadOperations statement = readOperationsInNewTransaction();
Iterator<ConstraintDescriptor> constraints = statement.constraintsGetForSchema(descriptor);
assertEquals(constraint, single(constraints));
}
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class UniquenessConstraintCreationIT method shouldNotDropUniquePropertyConstraintThatDoesNotExistWhenThereIsAPropertyExistenceConstraint.
@Test
public void shouldNotDropUniquePropertyConstraintThatDoesNotExistWhenThereIsAPropertyExistenceConstraint() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.nodePropertyExistenceConstraintCreate(descriptor);
commit();
// when
try {
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.constraintDrop(ConstraintDescriptorFactory.uniqueForSchema(descriptor));
fail("expected exception");
}// then
catch (DropConstraintFailureException e) {
assertThat(e.getCause(), instanceOf(NoSuchConstraintException.class));
} finally {
rollback();
}
// then
{
ReadOperations statement = readOperationsInNewTransaction();
Iterator<ConstraintDescriptor> constraints = statement.constraintsGetForSchema(descriptor);
assertEquals(ConstraintDescriptorFactory.existsForSchema(descriptor), single(constraints));
}
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class UniquenessConstraintCreationIT method shouldDropConstraintIndexWhenDroppingConstraint.
@Test
public void shouldDropConstraintIndexWhenDroppingConstraint() throws Exception {
// given
Statement statement = statementInNewTransaction(SecurityContext.AUTH_DISABLED);
UniquenessConstraintDescriptor constraint = statement.schemaWriteOperations().uniquePropertyConstraintCreate(descriptor);
assertEquals(asSet(uniqueIndex), asSet(statement.readOperations().uniqueIndexesGetAll()));
commit();
// when
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.constraintDrop(constraint);
commit();
// then
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.uniqueIndexesGetAll()));
commit();
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class AbstractConstraintCreationIT method shouldBeAbleToStoreAndRetrieveConstraint.
@Test
public void shouldBeAbleToStoreAndRetrieveConstraint() throws Exception {
// given
Statement statement = statementInNewTransaction(SecurityContext.AUTH_DISABLED);
// when
ConstraintDescriptor constraint = createConstraint(statement.schemaWriteOperations(), descriptor);
// then
assertEquals(constraint, single(statement.readOperations().constraintsGetAll()));
// given
commit();
ReadOperations readOperations = readOperationsInNewTransaction();
// when
Iterator<?> constraints = readOperations.constraintsGetAll();
// then
assertEquals(constraint, single(constraints));
}
Aggregations