use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class SQLDeleteEdgeTest method testDropClassVandEwithDeleteElements.
public void testDropClassVandEwithDeleteElements() {
database.command(new OCommandSQL("CREATE CLASS SuperE extends E")).execute();
database.command(new OCommandSQL("CREATE CLASS SuperV extends V")).execute();
OIdentifiable v1 = database.command(new OCommandSQL("create vertex SuperV set name = 'Luca'")).execute();
OIdentifiable v2 = database.command(new OCommandSQL("create vertex SuperV set name = 'Mark'")).execute();
database.command(new OCommandSQL("CREATE EDGE SuperE from " + v1.getIdentity() + " to " + v2.getIdentity())).execute();
try {
database.command(new OCommandSQL("DROP CLASS SuperV")).execute();
Assert.assertTrue(false);
} catch (OCommandExecutionException e) {
Assert.assertTrue(true);
}
try {
database.command(new OCommandSQL("DROP CLASS SuperE")).execute();
Assert.assertTrue(false);
} catch (OCommandExecutionException e) {
Assert.assertTrue(true);
}
int deleted = database.command(new OCommandSQL("DELETE VERTEX SuperV")).execute();
try {
database.command(new OCommandSQL("DROP CLASS SuperV")).execute();
Assert.assertTrue(true);
} catch (OCommandExecutionException e) {
Assert.assertTrue(false);
}
try {
database.command(new OCommandSQL("DROP CLASS SuperE")).execute();
Assert.assertTrue(true);
} catch (OCommandExecutionException e) {
Assert.assertTrue(false);
}
}
use of com.orientechnologies.orient.core.exception.OCommandExecutionException in project orientdb by orientechnologies.
the class SQLDropPropertyIndexTest method testForcePropertyDisabledBrokenCase.
@Test
public void testForcePropertyDisabledBrokenCase() throws Exception {
database.command(new OCommandSQL("CREATE INDEX DropPropertyIndexCompositeIndex ON DropPropertyIndexTestClass (prop1, prop2) UNIQUE")).execute();
try {
database.command(new OCommandSQL("DROP PROPERTY DropPropertyIndextestclaSS.proP1")).execute();
Assert.fail();
} catch (OCommandExecutionException e) {
Assert.assertTrue(e.getMessage().contains("Property used in indexes (" + "DropPropertyIndexCompositeIndex" + "). Please drop these indexes before removing property or use FORCE parameter."));
}
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("DropPropertyIndexTestClass").getClassIndex("DropPropertyIndexCompositeIndex");
Assert.assertNotNull(index);
final OIndexDefinition indexDefinition = index.getDefinition();
Assert.assertTrue(indexDefinition instanceof OCompositeIndexDefinition);
Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop1", "prop2"));
Assert.assertEquals(indexDefinition.getTypes(), new OType[] { EXPECTED_PROP1_TYPE, EXPECTED_PROP2_TYPE });
Assert.assertEquals(index.getType(), "UNIQUE");
}
Aggregations