use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class IndexIT method shouldFailToCreateIndexWhereAConstraintAlreadyExists.
@Test
public void shouldFailToCreateIndexWhereAConstraintAlreadyExists() throws Exception {
// given
{
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.uniquePropertyConstraintCreate(SchemaBoundary.map(descriptor));
commit();
}
// when
try {
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.indexCreate(SchemaBoundary.map(descriptor));
commit();
fail("expected exception");
}// then
catch (SchemaKernelException e) {
assertEquals("Label '" + LABEL + "' and property '" + PROPERTY_KEY + "' have a unique constraint defined" + " on them, so an index is already created that matches this.", e.getMessage());
}
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class IndexIT method shouldNotListConstraintIndexesAmongIndexes.
@Test
public void shouldNotListConstraintIndexesAmongIndexes() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.uniquePropertyConstraintCreate(SchemaBoundary.map(descriptor));
commit();
// then/when
ReadOperations readOperations = readOperationsInNewTransaction();
assertFalse(readOperations.indexesGetAll().hasNext());
assertFalse(readOperations.indexesGetForLabel(labelId).hasNext());
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class IndexIT method shouldNotListIndexesAmongConstraintIndexes.
@Test
public void shouldNotListIndexesAmongConstraintIndexes() throws Exception {
// given
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
commit();
// then/when
ReadOperations readOperations = readOperationsInNewTransaction();
assertFalse(readOperations.uniqueIndexesGetAll().hasNext());
assertFalse(readOperations.uniqueIndexesGetForLabel(labelId).hasNext());
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class IndexIT method shouldDisallowDroppingIndexThatDoesNotExist.
@Test
public void shouldDisallowDroppingIndexThatDoesNotExist() throws Exception {
// given
NewIndexDescriptor index;
{
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
index = statement.indexCreate(SchemaBoundary.map(descriptor));
commit();
}
{
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.indexDrop(index);
commit();
}
// when
try {
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
statement.indexDrop(index);
commit();
}// then
catch (SchemaKernelException e) {
assertEquals("Unable to drop index on :label[" + labelId + "](property[" + propertyKeyId + "]): " + "No such INDEX ON :label[" + labelId + "](property[" + propertyKeyId + "]).", e.getMessage());
}
}
use of org.neo4j.kernel.api.SchemaWriteOperations in project neo4j by neo4j.
the class IndexIT method rollBackIndexRuleShouldNotBeCommitted.
@Test
public void rollBackIndexRuleShouldNotBeCommitted() throws Exception {
// GIVEN
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
// WHEN
schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
// don't mark as success
rollback();
// THEN
ReadOperations readOperations = readOperationsInNewTransaction();
assertEquals(emptySetOf(NewIndexDescriptor.class), asSet(readOperations.indexesGetForLabel(labelId)));
commit();
}
Aggregations