use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedNodeRest.
@Test
public void shouldFailIfTryingToReturnPropsOfDeletedNodeRest() {
// given
executeTransactionally("CREATE (:NodeToDelete {p: 'a property'})");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("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 shouldHandleDurationArraysUsingRestResultDataContent.
@Test
public void shouldHandleDurationArraysUsingRestResultDataContent() throws Exception {
// Given
var db = getDefaultDatabase();
Duration duration = Duration.ofSeconds(73);
try (Transaction tx = db.beginTx()) {
Node node = tx.createNode(label("N"));
node.setProperty("durations", new Duration[] { duration });
tx.commit();
}
// When
HTTP.Response response = runQuery("MATCH (n:N) RETURN n", "rest");
// Then
assertEquals(200, response.status());
assertNoErrors(response);
JsonNode row = response.get("results").get(0).get("data").get(0).get("rest").get(0).get("data").get("durations").get(0);
assertEquals("\"PT1M13S\"", row.toString());
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedRelationshipsRow.
@Test
public void shouldBeAbleToReturnDeletedRelationshipsRow() {
// given
executeTransactionally("CREATE (:Start)-[:R {p: 'a property'}]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (s)-[r:R]->(e) DELETE r RETURN r"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(rowContainsDeletedEntities(0, 1));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(2L);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method returningADeletedPathRow.
@Test
public void returningADeletedPathRow() {
// given
executeTransactionally("CREATE (:Start)-[:R]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRow("MATCH p=(s)-[r:R]->(e) DELETE p RETURN p"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(rowContainsDeletedEntitiesInPath(2, 1));
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 setUp.
@BeforeEach
public void setUp() {
// begin
Response begin = http.POST(txUri());
assertThat(begin.status()).isEqualTo(201);
assertHasTxLocation(begin);
try {
commitResource = begin.stringFromContent("commit");
} catch (JsonParseException e) {
fail("Exception caught when setting up test: " + e.getMessage());
}
assertThat(commitResource).isEqualTo(begin.location() + "/commit");
}
Aggregations