use of org.neo4j.kernel.api.SchemaWriteOperations 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.SchemaWriteOperations in project neo4j by neo4j.
the class AbstractConstraintCreationIT method shouldBeAbleToResolveConflictsAndRecreateConstraintAfterFailingToCreateItDueToConflict.
@Test
public void shouldBeAbleToResolveConflictsAndRecreateConstraintAfterFailingToCreateItDueToConflict() throws Exception {
// given
try (Transaction tx = db.beginTx()) {
createOffendingDataInRunningTx(db);
tx.success();
}
// when
try (Transaction tx = db.beginTx()) {
createConstraintInRunningTx(db, KEY, PROP);
tx.success();
fail("expected failure");
} catch (QueryExecutionException e) {
assertThat(e.getMessage(), startsWith("Unable to create CONSTRAINT"));
}
try (Transaction tx = db.beginTx()) {
removeOffendingDataInRunningTx(db);
tx.success();
}
// then - this should not fail
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
createConstraint(statement, descriptor);
commit();
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class KernelTransactionSecurityContextTest method shouldAllowSchemaWriteAccessInFullMode.
@Test
public void shouldAllowSchemaWriteAccessInFullMode() throws Throwable {
// Given
KernelTransactionImplementation tx = newTransaction(AUTH_DISABLED);
// When
SchemaWriteOperations writes = tx.acquireStatement().schemaWriteOperations();
// Then
assertNotNull(writes);
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class IndexIT method addIndexRuleInATransaction.
@Test
public void addIndexRuleInATransaction() throws Exception {
// GIVEN
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
// WHEN
NewIndexDescriptor expectedRule = schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
commit();
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(asSet(expectedRule), asSet(readOperations.indexesGetForLabel(labelId)));
assertEquals(expectedRule, readOperations.indexGetForLabelAndPropertyKey(descriptor));
commit();
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class UniquenessConstraintValidationIT method createConstraint.
private void createConstraint(String label, String propertyKey) throws KernelException {
//TODO: Consider testing composite indexes
int labelId, propertyKeyId;
TokenWriteOperations tokenWriteOperations = tokenWriteOperationsInNewTransaction();
labelId = tokenWriteOperations.labelGetOrCreateForName(label);
propertyKeyId = tokenWriteOperations.propertyKeyGetOrCreateForName(propertyKey);
commit();
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.uniquePropertyConstraintCreate(forLabel(labelId, propertyKeyId));
commit();
}
Aggregations