use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexIT method shouldDisallowDroppingIndexByNameThatBelongsToConstraint.
@Test
void shouldDisallowDroppingIndexByNameThatBelongsToConstraint() throws KernelException {
// given
String constraintName = "my constraint";
{
SchemaWrite statement = schemaWriteInNewTransaction();
statement.uniquePropertyConstraintCreate(uniqueForSchema(schema).withName("constraint name"));
commit();
}
// when
SchemaWrite statement = schemaWriteInNewTransaction();
SchemaKernelException e = assertThrows(SchemaKernelException.class, () -> statement.indexDrop(constraintName));
assertEquals("Unable to drop index called `my constraint`. There is no such index.", e.getMessage());
rollback();
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexIT method shouldBeAbleToRemoveAConstraintIndexWithoutOwner.
@Test
void shouldBeAbleToRemoveAConstraintIndexWithoutOwner() throws Exception {
// given
AssertableLogProvider logProvider = new AssertableLogProvider();
ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, logProvider);
IndexProviderDescriptor provider = GenericNativeIndexProvider.DESCRIPTOR;
IndexPrototype prototype = uniqueForSchema(schema).withName("constraint name").withIndexProvider(provider);
IndexDescriptor constraintIndex = creator.createConstraintIndex(prototype);
// then
KernelTransaction transaction = newTransaction();
assertEquals(emptySet(), asSet(transaction.schemaRead().constraintsGetForLabel(labelId)));
commit();
// when
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
schemaWrite.indexDrop(constraintIndex);
commit();
// then
transaction = newTransaction();
assertEquals(emptySet(), asSet(transaction.schemaRead().indexesGetForLabel(labelId)));
commit();
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexIT method rollBackIndexRuleShouldNotBeCommitted.
@Test
void rollBackIndexRuleShouldNotBeCommitted() throws Exception {
// GIVEN
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// WHEN
schemaWrite.indexCreate(schema, "my index");
// don't mark as success
rollback();
// THEN
KernelTransaction transaction = newTransaction();
assertEquals(emptySet(), asSet(transaction.schemaRead().indexesGetForLabel(labelId)));
commit();
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexIT method shouldListAll.
@Test
void shouldListAll() throws Exception {
// given
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
IndexDescriptor index1 = schemaWrite.indexCreate(schema, "my index");
IndexBackedConstraintDescriptor constraint = schemaWrite.uniquePropertyConstraintCreate(uniqueForSchema(schema2).withName("constraint name")).asIndexBackedConstraint();
commit();
// then/when
SchemaRead schemaRead = newTransaction().schemaRead();
IndexDescriptor index2 = Iterators.single(schemaRead.index(constraint.schema()));
List<IndexDescriptor> indexes = Iterators.asList(schemaRead.indexesGetAll());
assertThat(indexes).contains(index1, index2);
commit();
}
use of org.neo4j.internal.kernel.api.SchemaWrite in project neo4j by neo4j.
the class IndexIT method committedAndTransactionalIndexRulesShouldBeMerged.
@Test
void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception {
// GIVEN
SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction();
IndexDescriptor existingRule = schemaWriteOperations.indexCreate(schema, "my index");
commit();
// WHEN
KernelTransaction transaction = newTransaction(AUTH_DISABLED);
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyKeyId2);
IndexDescriptor addedRule = transaction.schemaWrite().indexCreate(schema, "my other index");
Set<IndexDescriptor> indexRulesInTx = asSet(transaction.schemaRead().indexesGetForLabel(labelId));
commit();
// THEN
assertEquals(asSet(existingRule, addedRule), indexRulesInTx);
}
Aggregations