use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class AbstractConstraintCreationIT method shouldBeAbleToResolveConflictsAndRecreateConstraintAfterFailingToCreateItDueToConflict.
@Test
public void shouldBeAbleToResolveConflictsAndRecreateConstraintAfterFailingToCreateItDueToConflict() throws Exception {
// given
try (Transaction tx = db.beginTx()) {
createOffendingDataInRunningTx(db);
tx.success();
}
// when
try (Transaction tx = db.beginTx()) {
createConstraintInRunningTx(db, KEY, PROP);
tx.success();
fail("expected failure");
} catch (QueryExecutionException e) {
assertThat(e.getMessage(), startsWith("Unable to create CONSTRAINT"));
}
try (Transaction tx = db.beginTx()) {
removeOffendingDataInRunningTx(db);
tx.success();
}
// then - this should not fail
SchemaWriteOperations statement = schemaWriteOperationsInNewTransaction();
createConstraint(statement, descriptor);
commit();
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class DatabaseManagementServiceImpl method systemDatabaseExecute.
private void systemDatabaseExecute(String query, SystemDatabaseExecutionContext beforeCommitHook) {
try {
GraphDatabaseAPI database = (GraphDatabaseAPI) database(SYSTEM_DATABASE_NAME);
try (InternalTransaction transaction = database.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED)) {
transaction.execute(query);
beforeCommitHook.accept(database, transaction);
transaction.commit();
}
} catch (QueryExecutionException | KernelException e) {
throw new DatabaseManagementException(e);
}
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class FixturesTestIT method shouldHandleFixturesWithSyntaxErrorsGracefully.
@Test
void shouldHandleFixturesWithSyntaxErrorsGracefully() throws Exception {
// Given two files in the root folder
Path targetFolder = testDir.homePath();
writeFixture(targetFolder.resolve("fixture1.cyp"), "this is not a valid cypher statement");
// When
try (Neo4j ignore = getServerBuilder(targetFolder).withFixture(targetFolder).build()) {
fail("Should have thrown exception");
} catch (QueryExecutionException e) {
assertThat(e.getStatusCode()).isEqualTo("Neo.ClientError.Statement.SyntaxError");
}
}
use of org.neo4j.graphdb.QueryExecutionException in project neo4j by neo4j.
the class QueryRestartIT method queryThatModifiesDataAndSeesUnstableSnapshotShouldThrowException.
@Test
void queryThatModifiesDataAndSeesUnstableSnapshotShouldThrowException() {
try (Transaction transaction = database.beginTx()) {
QueryExecutionException e = assertThrows(QueryExecutionException.class, () -> transaction.execute("MATCH (n:toRetry) CREATE () RETURN n.c"));
assertEquals("Unable to get clean data snapshot for query " + "'MATCH (n:toRetry) CREATE () RETURN n.c' that performs updates.", e.getMessage());
transaction.commit();
}
}
Aggregations