use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class BuiltInProcedures method listConstraints.
@Description("List all constraints in the database.")
@Procedure(name = "db.constraints", mode = READ)
public Stream<ConstraintResult> listConstraints() {
Statement statement = tx.acquireStatement();
ReadOperations operations = statement.readOperations();
TokenNameLookup tokens = new StatementTokenNameLookup(operations);
return asList(operations.constraintsGetAll()).stream().map((constraint) -> constraint.prettyPrint(tokens)).sorted().map(ConstraintResult::new).onClose(statement::close);
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method shouldNotListConstraintIndexesAmongIndexes.
@Test
public void shouldNotListConstraintIndexesAmongIndexes() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.uniquePropertyConstraintCreate(SchemaBoundary.map(descriptor));
commit();
// then/when
ReadOperations readOperations = readOperationsInNewTransaction();
assertFalse(readOperations.indexesGetAll().hasNext());
assertFalse(readOperations.indexesGetForLabel(labelId).hasNext());
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method shouldNotListIndexesAmongConstraintIndexes.
@Test
public void shouldNotListIndexesAmongConstraintIndexes() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
commit();
// then/when
ReadOperations readOperations = readOperationsInNewTransaction();
assertFalse(readOperations.uniqueIndexesGetAll().hasNext());
assertFalse(readOperations.uniqueIndexesGetForLabel(labelId).hasNext());
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method rollBackIndexRuleShouldNotBeCommitted.
@Test
public void rollBackIndexRuleShouldNotBeCommitted() throws Exception {
// GIVEN
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
// WHEN
schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
// don't mark as success
rollback();
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.indexesGetForLabel(labelId)));
commit();
}
use of org.neo4j.kernel.api.ReadOperations in project neo4j by neo4j.
the class IndexIT method shouldRemoveAConstraintIndexWithoutOwnerInRecovery.
@Test
public void shouldRemoveAConstraintIndexWithoutOwnerInRecovery() throws Exception {
// given
PropertyAccessor propertyAccessor = mock(PropertyAccessor.class);
ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, propertyAccessor, false);
creator.createConstraintIndex(SchemaBoundary.map(descriptor));
// when
restartDb();
// then
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.indexesGetForLabel(labelId)));
commit();
}
Aggregations