use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin_and_execute_periodic_commit_that_returns_data_and_commit.
@Test
public void begin_and_execute_periodic_commit_that_returns_data_and_commit() throws Exception {
int nodes = 11;
int batch = 2;
ServerTestUtils.withCSVFile(nodes, url -> {
long nodesInDatabaseBeforeTransaction = countNodes();
long txIdBefore = resolveDependency(TransactionIdStore.class).getLastClosedTransactionId();
Response response = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'USING PERIODIC COMMIT " + batch + " LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE (n {id: 23}) RETURN n' } ] }"));
long txIdAfter = resolveDependency(TransactionIdStore.class).getLastClosedTransactionId();
assertThat(response.status(), equalTo(200));
assertThat(response, containsNoErrors());
JsonNode columns = response.get("results").get(0).get("columns");
assertThat(columns.toString(), equalTo("[\"n\"]"));
assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + nodes));
assertThat(txIdAfter, equalTo(txIdBefore + ((nodes / batch) + 1)));
});
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedNodeGraph.
@Test
public void shouldFailIfTryingToReturnPropsOfDeletedNodeGraph() {
// given
graphdb().execute("CREATE (:NodeToDelete {p: 'a property'})");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (n:NodeToDelete) DELETE n RETURN n.p"));
assertThat(commit, hasErrors(Status.Statement.EntityNotFound));
assertThat(commit.status(), equalTo(200));
assertThat(nodesInDatabase(), equalTo(1L));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class RowFormatMetaFieldTest method metaFieldShouldGetCorrectIndex.
@Test
public void metaFieldShouldGetCorrectIndex() {
// given
graphdb().execute("CREATE (:Start)-[:R]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (s:Start)-[r:R]->(e:End) RETURN s, r, 1, e"));
assertThat(commit, containsNoErrors());
assertThat(commit, rowContainsMetaNodesAtIndex(0, 3));
assertThat(commit, rowContainsMetaRelsAtIndex(1));
assertThat(commit.status(), equalTo(200));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin_and_execute_and_commit.
@Test
public void begin_and_execute_and_commit() throws Exception {
long nodesInDatabaseBeforeTransaction = countNodes();
// begin and execute and commit
Response begin = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
assertThat(begin.status(), equalTo(200));
assertThat(begin, containsNoErrors());
assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 1));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin_and_execute_periodic_commit_followed_by_another_statement_and_commit.
@Test
public void begin_and_execute_periodic_commit_followed_by_another_statement_and_commit() throws Exception {
ServerTestUtils.withCSVFile(1, url -> {
Response response = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'USING PERIODIC COMMIT LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE (n {id: 23}) RETURN n' }, { 'statement': 'RETURN 1' } ] }"));
assertThat(response.status(), equalTo(200));
assertThat(response, hasErrors(Status.Statement.SemanticError));
});
}
Aggregations