use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldDropIndexBySchema.
@Test
void shouldDropIndexBySchema() throws Exception {
IndexDescriptor index;
try (KernelTransaction transaction = beginTransaction()) {
index = transaction.schemaWrite().indexCreate(forLabel(label, prop1), "my index");
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
transaction.schemaWrite().indexDrop(index.schema());
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaRead schemaRead = transaction.schemaRead();
assertFalse(schemaRead.index(SchemaDescriptor.forLabel(label, prop1)).hasNext());
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldDropConstraintByName.
@Test
void shouldDropConstraintByName() throws Exception {
ConstraintDescriptor constraint;
String constraintName = "my constraint";
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().uniquePropertyConstraintCreate(uniqueForSchema(forLabel(label, prop1)).withName(constraintName));
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
transaction.schemaWrite().constraintDrop(constraintName);
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaRead schemaRead = transaction.schemaRead();
assertFalse(schemaRead.constraintExists(constraint));
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldSeeNodeKeyConstraintFromTransaction.
@Test
void shouldSeeNodeKeyConstraintFromTransaction() throws Exception {
ConstraintDescriptor existing;
try (KernelTransaction transaction = beginTransaction()) {
existing = transaction.schemaWrite().nodeKeyConstraintCreate(uniqueForSchema(forLabel(label, prop1)).withName("existing constraint"));
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaReadCore before = transaction.schemaRead().snapshot();
ConstraintDescriptor newConstraint = transaction.schemaWrite().nodeKeyConstraintCreate(uniqueForSchema(forLabel(label, prop2)).withName("new constraint"));
SchemaRead schemaRead = transaction.schemaRead();
assertTrue(schemaRead.constraintExists(existing));
assertTrue(schemaRead.constraintExists(newConstraint));
assertThat(asList(schemaRead.constraintsGetForLabel(label))).contains(existing, newConstraint);
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).contains(existing, newConstraint);
assertThat(asList(before.constraintsGetForLabel(label))).contains(existing, newConstraint);
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldDropNodeKeyConstraint.
@Test
void shouldDropNodeKeyConstraint() throws Exception {
ConstraintDescriptor constraint;
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().nodeKeyConstraintCreate(uniqueForSchema(forLabel(label, prop1)));
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
transaction.schemaWrite().constraintDrop(constraint);
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaRead schemaRead = transaction.schemaRead();
assertFalse(schemaRead.constraintExists(constraint));
assertThat(asList(schemaRead.constraintsGetForLabel(label))).isEmpty();
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).isEmpty();
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldNotSeeDroppedRelationshipPropertyExistenceConstraintFromTransaction.
@Test
void shouldNotSeeDroppedRelationshipPropertyExistenceConstraintFromTransaction() throws Exception {
ConstraintDescriptor existing;
try (KernelTransaction transaction = beginTransaction()) {
existing = transaction.schemaWrite().relationshipPropertyExistenceConstraintCreate(forRelType(type, prop1), "constraint name");
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaReadCore before = transaction.schemaRead().snapshot();
transaction.schemaWrite().constraintDrop(existing);
SchemaRead schemaRead = transaction.schemaRead();
assertFalse(schemaRead.constraintExists(existing));
assertFalse(schemaRead.index(SchemaDescriptor.forLabel(type, prop2)).hasNext());
assertThat(asList(schemaRead.constraintsGetForLabel(label))).isEmpty();
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).isEmpty();
assertThat(asList(before.constraintsGetForLabel(label))).isEmpty();
}
}
Aggregations