use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldCreateNodePropertyExistenceConstraint.
@Test
void shouldCreateNodePropertyExistenceConstraint() throws Exception {
ConstraintDescriptor constraint;
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().nodePropertyExistenceConstraintCreate(forLabel(label, prop1), "constraint name");
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaRead schemaRead = transaction.schemaRead();
assertTrue(schemaRead.constraintExists(constraint));
assertThat(asList(schemaRead.constraintsGetForLabel(label))).isEqualTo(singletonList(constraint));
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).isEqualTo(singletonList(constraint));
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldDropNodePropertyExistenceConstraint.
@Test
void shouldDropNodePropertyExistenceConstraint() throws Exception {
ConstraintDescriptor constraint;
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().nodePropertyExistenceConstraintCreate(forLabel(label, 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.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 shouldNotSeeDroppedIndexFromTransaction.
@Test
void shouldNotSeeDroppedIndexFromTransaction() 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);
SchemaRead schemaRead = transaction.schemaRead();
assertFalse(schemaRead.index(index.schema()).hasNext());
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldCreateUniquePropertyConstraint.
@Test
void shouldCreateUniquePropertyConstraint() throws Exception {
ConstraintDescriptor constraint;
try (KernelTransaction transaction = beginTransaction()) {
constraint = transaction.schemaWrite().uniquePropertyConstraintCreate(uniqueForSchema(forLabel(label, prop1)));
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaRead schemaRead = transaction.schemaRead();
assertTrue(schemaRead.constraintExists(constraint));
assertThat(asList(schemaRead.constraintsGetForLabel(label))).isEqualTo(singletonList(constraint));
assertThat(asList(schemaRead.snapshot().constraintsGetForLabel(label))).isEqualTo(singletonList(constraint));
}
}
use of org.neo4j.internal.kernel.api.SchemaRead in project neo4j by neo4j.
the class SchemaReadWriteTestBase method shouldDropInByName.
@Test
void shouldDropInByName() throws Exception {
String indexName = "My fancy index";
try (KernelTransaction transaction = beginTransaction()) {
transaction.schemaWrite().indexCreate(forLabel(label, prop1), indexName);
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
transaction.schemaWrite().indexDrop(indexName);
transaction.commit();
}
try (KernelTransaction transaction = beginTransaction()) {
SchemaRead schemaRead = transaction.schemaRead();
assertFalse(schemaRead.index(SchemaDescriptor.forLabel(label, prop1)).hasNext());
}
}
Aggregations