use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedNodeGraph.
@Test
public void shouldFailIfTryingToReturnPropsOfDeletedNodeGraph() {
// given
executeTransactionally("CREATE (:NodeToDelete {p: 'a property'})");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (n:NodeToDelete) DELETE n RETURN n.p"));
assertThat(commit).satisfies(hasErrors(Status.Statement.EntityNotFound));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(1L);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedEntitiesRest.
@Test
public void shouldBeAbleToReturnDeletedEntitiesRest() {
// given
executeTransactionally("CREATE (:Start)-[:R]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (s:Start)-[r:R]->(e:End) DELETE s, r, e RETURN *"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(restContainsDeletedEntities(3));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(0L);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnLabelsOfDeletedNodeRow.
@Test
public void shouldFailIfTryingToReturnLabelsOfDeletedNodeRow() {
// given
executeTransactionally("CREATE (:NodeToDelete)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (n:NodeToDelete) DELETE n RETURN labels(n)"));
assertThat(commit).satisfies(hasErrors(Status.Statement.EntityNotFound));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(1L);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnLabelsOfDeletedNodeRest.
@Test
public void shouldFailIfTryingToReturnLabelsOfDeletedNodeRest() {
// given
executeTransactionally("CREATE (:NodeToDelete)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (n:NodeToDelete) DELETE n RETURN labels(n)"));
assertThat(commit).satisfies(hasErrors(Status.Statement.EntityNotFound));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(1L);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method should_include_graph_format_when_requested.
@Test
public void should_include_graph_format_when_requested() throws Exception {
long initialData = countNodes("Foo");
// given
http.POST("/db/data/transaction/commit", singleStatement("CREATE (n:Foo:Bar)"));
// when
Response response = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'MATCH (n:Foo) RETURN n', 'resultDataContents':['row'," + "'graph'] } ] }"));
// then
assertThat(response.status(), equalTo(200));
JsonNode data = response.get("results").get(0).get("data");
assertTrue("data is a list", data.isArray());
assertEquals("one entry", initialData + 1, data.size());
JsonNode entry = data.get(0);
assertTrue("entry has row", entry.has("row"));
assertTrue("entry has graph", entry.has("graph"));
JsonNode nodes = entry.get("graph").get("nodes"), rels = entry.get("graph").get("relationships");
assertTrue("nodes is a list", nodes.isArray());
assertTrue("relationships is a list", rels.isArray());
assertEquals("one node", 1, nodes.size());
assertEquals("no relationships", 0, rels.size());
Set<String> labels = new HashSet<>();
for (JsonNode node : nodes.get(0).get("labels")) {
labels.add(node.getTextValue());
}
assertEquals("labels", asSet("Foo", "Bar"), labels);
}
Aggregations