use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldNotFindNonExistentIndex.
@Test
void shouldNotFindNonExistentIndex() throws Exception {
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 shouldDropRelationshipPropertyExistenceConstraint.
@Test
void shouldDropRelationshipPropertyExistenceConstraint() throws Exception {
ConstraintDescriptor constraint;
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().relationshipPropertyExistenceConstraintCreate(forRelType(type, prop1), "constraint name");
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.constraintsGetForRelationshipType(type))).isEmpty();
assertThat(asList(schemaRead.snapshot().constraintsGetForRelationshipType(type))).isEmpty();
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldNotSeeDroppedNodePropertyExistenceConstraintFromTransaction.
@Test
void shouldNotSeeDroppedNodePropertyExistenceConstraintFromTransaction() throws Exception {
ConstraintDescriptor existing;
try (KernelTransaction transaction = beginTransaction()) {
existing = transaction.schemaWrite().nodePropertyExistenceConstraintCreate(forLabel(label, 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(label, prop2)).hasNext());
assertThat(asList(schemaRead.constraintsGetForLabel(label))).isEmpty();
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).isEmpty();
assertThat(asList(before.constraintsGetForLabel(label))).isEmpty();
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldDropUniquePropertyConstraint.
@Test
void shouldDropUniquePropertyConstraint() throws Exception {
ConstraintDescriptor constraint;
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().uniquePropertyConstraintCreate(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 shouldNotSeeDroppedNodeKeyConstraintFromTransaction.
@Test
void shouldNotSeeDroppedNodeKeyConstraintFromTransaction() throws Exception {
ConstraintDescriptor existing;
try (KernelTransaction transaction = beginTransaction()) {
existing = transaction.schemaWrite().nodeKeyConstraintCreate(uniqueForSchema(forLabel(label, prop1)).withName("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));
assertThat(asList(schemaRead.constraintsGetForLabel(label))).isEmpty();
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).isEmpty();
assertThat(asList(before.constraintsGetForLabel(label))).isEmpty();
}
}
Aggregations