use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnLabelsOfDeletedNodeGraph.
@Test
public void shouldFailIfTryingToReturnLabelsOfDeletedNodeGraph() {
// given
graphdb().execute("CREATE (:NodeToDelete)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (n:NodeToDelete) DELETE n RETURN labels(n)"));
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 BatchEndpointIT method requestsShouldNotFailWhenHttpLoggingIsOn.
@Test
public void requestsShouldNotFailWhenHttpLoggingIsOn() {
// Given
String body = "[" + "{'method': 'POST', 'to': '/node', 'body': {'age': 1}, 'id': 1} ]";
// When
Response response = withBaseUri(neo4j.httpURI().toString()).withHeaders("Content-Type", "application/json").POST("db/data/batch", quotedJson(body));
// Then
assertEquals(200, response.status());
}
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);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__execute__execute__commit.
@Test
public void begin__execute__execute__commit() throws Exception {
long nodesInDatabaseBeforeTransaction = countNodes();
// begin
Response begin = http.POST("/db/data/transaction");
String commitResource = begin.stringFromContent("commit");
// execute
http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ]" + " }"));
// execute
http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ]" + " }"));
// commit
http.POST(commitResource);
assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 2));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method restFormatNodesShouldHaveSensibleUris.
@Test
public void restFormatNodesShouldHaveSensibleUris() throws Throwable {
// given
final String hostname = "localhost";
final String scheme = "http";
// when
Response rs = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'CREATE (n:Foo:Bar) RETURN n', 'resultDataContents':['rest'] } ] }"));
// then
JsonNode restNode = rs.get("results").get(0).get("data").get(0).get("rest").get(0);
assertPath(restNode.get("labels"), "/node/\\d+/labels", hostname, scheme);
assertPath(restNode.get("outgoing_relationships"), "/node/\\d+/relationships/out", hostname, scheme);
assertPath(restNode.get("traverse"), "/node/\\d+/traverse/\\{returnType\\}", hostname, scheme);
assertPath(restNode.get("all_typed_relationships"), "/node/\\d+/relationships/all/\\{-list\\|&\\|types\\}", hostname, scheme);
assertPath(restNode.get("self"), "/node/\\d+", hostname, scheme);
assertPath(restNode.get("property"), "/node/\\d+/properties/\\{key\\}", hostname, scheme);
assertPath(restNode.get("properties"), "/node/\\d+/properties", hostname, scheme);
assertPath(restNode.get("outgoing_typed_relationships"), "/node/\\d+/relationships/out/\\{-list\\|&\\|types\\}", hostname, scheme);
assertPath(restNode.get("incoming_relationships"), "/node/\\d+/relationships/in", hostname, scheme);
assertPath(restNode.get("create_relationship"), "/node/\\d+/relationships", hostname, scheme);
assertPath(restNode.get("paged_traverse"), "/node/\\d+/paged/traverse/\\{returnType\\}\\{\\?pageSize," + "leaseTime\\}", "localhost", scheme);
assertPath(restNode.get("all_relationships"), "/node/\\d+/relationships/all", hostname, scheme);
assertPath(restNode.get("incoming_typed_relationships"), "/node/\\d+/relationships/in/\\{-list\\|&\\|types\\}", hostname, scheme);
}
Aggregations