use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method shouldWorkWhenHittingTheASTCacheInCypher.
@Test
public void shouldWorkWhenHittingTheASTCacheInCypher() throws JsonParseException {
// give a cached plan
Response response = http.POST("/db/data/transaction/commit", singleStatement("MATCH (group:Group {name: \\\"AAA\\\"}) RETURN *"));
assertThat(response.status(), equalTo(200));
assertThat(response.get("errors").size(), equalTo(0));
// when we hit the ast cache
response = http.POST("/db/data/transaction/commit", singleStatement("MATCH (group:Group {name: \\\"BBB\\\"}) RETURN *"));
// then no errors (in particular no NPE)
assertThat(response.status(), equalTo(200));
assertThat(response.get("errors").size(), equalTo(0));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__rollback__commit.
@Test
public void begin__rollback__commit() throws Exception {
// begin
Response begin = http.POST("/db/data/transaction");
assertThat(begin.status(), equalTo(201));
assertHasTxLocation(begin);
String commitResource = begin.stringFromContent("commit");
// terminate
Response interrupt = http.DELETE(begin.location());
assertThat(interrupt.status(), equalTo(200));
// commit
Response commit = http.POST(commitResource);
assertThat(commit.status(), equalTo(404));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__execute__commit.
@Test
public void begin__execute__commit() throws Exception {
long nodesInDatabaseBeforeTransaction = countNodes();
// begin
Response begin = http.POST("/db/data/transaction");
assertThat(begin.status(), equalTo(201));
assertHasTxLocation(begin);
String commitResource = begin.stringFromContent("commit");
assertThat(commitResource, matches("http://localhost:\\d+/db/data/transaction/\\d+/commit"));
assertThat(begin.get("transaction").get("expires").asText(), isValidRFCTimestamp());
// execute
Response execute = http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
assertThat(execute.status(), equalTo(200));
assertThat(execute.get("transaction").get("expires").asText(), isValidRFCTimestamp());
// commit
Response commit = http.POST(commitResource);
assertThat(commit.status(), equalTo(200));
assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 1));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedNodesRest.
@Test
public void shouldBeAbleToReturnDeletedNodesRest() {
// given
graphdb().execute("CREATE (:NodeToDelete {p: 'a property'})");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (n:NodeToDelete) DELETE n RETURN n"));
assertThat(commit, containsNoErrors());
assertThat(commit, restContainsDeletedEntities(1));
assertThat(commit.status(), equalTo(200));
assertThat(nodesInDatabase(), equalTo(0L));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldNotMarkNormalEntitiesAsDeletedRest.
@Test
public void shouldNotMarkNormalEntitiesAsDeletedRest() {
// given
graphdb().execute("CREATE (:Start)-[:R]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (s:Start)-[r:R]->(e:End) RETURN *"));
assertThat(commit, containsNoErrors());
assertThat(commit, restContainsNoDeletedEntities());
assertThat(commit.status(), equalTo(200));
}
Aggregations