use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__execute__commit.
@ParameterizedTest
@MethodSource("argumentsProvider")
public void begin__execute__commit(String txUri) throws Exception {
this.txUri = txUri;
long nodesInDatabaseBeforeTransaction = countNodes();
// begin
Response begin = POST(txUri);
assertThat(begin.status()).isEqualTo(201);
assertHasTxLocation(begin, txUri);
String commitResource = begin.stringFromContent("commit");
assertThat(commitResource).matches(format("http://localhost:\\d+/%s/\\d+/commit", txUri));
assertThat(begin.get("transaction").get("expires").asText()).satisfies(validRFCTimestamp());
// execute
Response execute = POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
assertThat(execute.status()).isEqualTo(200);
assertThat(execute.get("transaction").get("expires").asText()).satisfies(validRFCTimestamp());
// commit
Response commit = POST(commitResource);
assertThat(commit.status()).isEqualTo(200);
assertThat(countNodes()).isEqualTo(nodesInDatabaseBeforeTransaction + 1);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class TransactionIT method begin__execute_and_commit.
@ParameterizedTest
@MethodSource("argumentsProvider")
public void begin__execute_and_commit(String txUri) throws Exception {
this.txUri = txUri;
long nodesInDatabaseBeforeTransaction = countNodes();
// begin
Response begin = POST(txUri);
assertThat(begin.status()).isEqualTo(201);
assertHasTxLocation(begin, txUri);
String commitResource = begin.stringFromContent("commit");
assertThat(commitResource).isEqualTo(begin.location() + "/commit");
// execute and commit
Response commit = POST(commitResource, quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit.status()).isEqualTo(200);
assertThat(countNodes()).isEqualTo(nodesInDatabaseBeforeTransaction + 1);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class JoltResultFormatIT method setUp.
@BeforeEach
void setUp() {
// begin
Response begin = http.POST(txUri());
assertThat(begin.status()).isEqualTo(201);
assertHasTxLocation(begin);
try {
commitResource = begin.get("info").get("commit").asText();
} catch (JsonParseException e) {
fail("Exception caught when setting up test: " + e.getMessage());
}
assertThat(commitResource).isEqualTo(begin.location() + "/commit");
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnLabelsOfDeletedNodeGraph.
@Test
public void shouldFailIfTryingToReturnLabelsOfDeletedNodeGraph() {
// given
executeTransactionally("CREATE (:NodeToDelete)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonGraph("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 returningAPartiallyDeletedPathRow.
@Test
public void returningAPartiallyDeletedPathRow() {
// given
String query = "CREATE (:Start)-[:R]->(:End)";
executeTransactionally(query);
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRow("MATCH p=(s)-[r:R]->(e) DELETE s,r RETURN p"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(rowContainsDeletedEntitiesInPath(1, 1));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(1L);
}
Aggregations