use of org.neo4j.kernel.api.exceptions.schema.SchemaKernelException 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.exceptions.schema.SchemaKernelException 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());
}
}
Aggregations