use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldHandleTemporalUsingRestResultDataContent.
@Test
public void shouldHandleTemporalUsingRestResultDataContent() throws Exception {
// Given
var db = getDefaultDatabase();
ZonedDateTime date = ZonedDateTime.of(1980, 3, 11, 0, 0, 0, 0, ZoneId.of("Europe/Stockholm"));
try (Transaction tx = db.beginTx()) {
Node node = tx.createNode(label("N"));
node.setProperty("date", date);
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("date");
assertEquals("\"1980-03-11T00:00+01:00[Europe/Stockholm]\"", row.toString());
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedNodesRest.
@Test
public void shouldBeAbleToReturnDeletedNodesRest() {
// given
executeTransactionally("CREATE (:NodeToDelete {p: 'a property'})");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (n:NodeToDelete) DELETE n RETURN n"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(restContainsDeletedEntities(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 shouldNotMarkNormalEntitiesAsDeletedRow.
@Test
public void shouldNotMarkNormalEntitiesAsDeletedRow() {
// given
executeTransactionally("CREATE (:Start)-[:R]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (s:Start)-[r:R]->(e:End) RETURN *"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(rowContainsNoDeletedEntities());
assertThat(commit.status()).isEqualTo(200);
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldHandleDurationUsingRestResultDataContent.
@Test
public void shouldHandleDurationUsingRestResultDataContent() throws Exception {
// Given
var db = getDefaultDatabase();
Duration duration = Duration.ofSeconds(73);
try (Transaction tx = db.beginTx()) {
Node node = tx.createNode(label("N"));
node.setProperty("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("duration");
assertEquals("\"PT1M13S\"", row.toString());
}
use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.
the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedRelationshipsRest.
@Test
public void shouldBeAbleToReturnDeletedRelationshipsRest() {
// given
executeTransactionally("CREATE (:Start)-[:R {p: 'a property'}]->(:End)");
// execute and commit
Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (s)-[r:R]->(e) DELETE r RETURN r"));
assertThat(commit).satisfies(containsNoErrors());
assertThat(commit).satisfies(restContainsDeletedEntities(1));
assertThat(commit.status()).isEqualTo(200);
assertThat(nodesInDatabase()).isEqualTo(2L);
}
Aggregations