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);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__execute__execute_and_periodic_commit.
@Test
public void begin__execute__execute_and_periodic_commit() throws Exception {
ServerTestUtils.withCSVFile(1, url -> {
Response begin = http.POST("/db/data/transaction");
http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE ()' } ] }"));
Response response = http.POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'USING" + " PERIODIC COMMIT LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE ()' } ] }"));
assertThat(response, hasErrors(Status.Statement.SemanticError));
});
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method correctStatusCodeWhenUsingHintWithoutAnyIndex.
@Test
public void correctStatusCodeWhenUsingHintWithoutAnyIndex() throws Exception {
// begin and execute and commit
Response begin = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': " + "'MATCH (n:Test) USING INDEX n:Test(foo) WHERE n.foo = 42 RETURN n.foo' } ] }"));
assertThat(begin, hasErrors(Status.Request.Schema.IndexNotFound));
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__execute_and_commit.
@Test
public void begin__execute_and_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, equalTo(begin.location() + "/commit"));
// execute and commit
Response commit = http.POST(commitResource, quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
assertThat(commit, containsNoErrors());
assertThat(commit.status(), equalTo(200));
assertThat(countNodes(), equalTo(nodesInDatabaseBeforeTransaction + 1));
}
Aggregations