Search in sources :

Example 76 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedNodeGraph.

@Test
public void shouldFailIfTryingToReturnPropsOfDeletedNodeGraph() {
    // given
    executeTransactionally("CREATE (:NodeToDelete {p: 'a property'})");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (n:NodeToDelete) DELETE n RETURN n.p"));
    assertThat(commit).satisfies(hasErrors(Status.Statement.EntityNotFound));
    assertThat(commit.status()).isEqualTo(200);
    assertThat(nodesInDatabase()).isEqualTo(1L);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.jupiter.api.Test)

Example 77 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedEntitiesRest.

@Test
public void shouldBeAbleToReturnDeletedEntitiesRest() {
    // given
    executeTransactionally("CREATE (:Start)-[:R]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (s:Start)-[r:R]->(e:End) DELETE s, r, e RETURN *"));
    assertThat(commit).satisfies(containsNoErrors());
    assertThat(commit).satisfies(restContainsDeletedEntities(3));
    assertThat(commit.status()).isEqualTo(200);
    assertThat(nodesInDatabase()).isEqualTo(0L);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.jupiter.api.Test)

Example 78 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class QueryResultsSerializationTest method shouldFailIfTryingToReturnLabelsOfDeletedNodeRow.

@Test
public void shouldFailIfTryingToReturnLabelsOfDeletedNodeRow() {
    // given
    executeTransactionally("CREATE (:NodeToDelete)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (n:NodeToDelete) DELETE n RETURN labels(n)"));
    assertThat(commit).satisfies(hasErrors(Status.Statement.EntityNotFound));
    assertThat(commit.status()).isEqualTo(200);
    assertThat(nodesInDatabase()).isEqualTo(1L);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.jupiter.api.Test)

Example 79 with Response

use of org.neo4j.test.server.HTTP.Response in project neo4j by neo4j.

the class QueryResultsSerializationTest method shouldFailIfTryingToReturnLabelsOfDeletedNodeRest.

@Test
public void shouldFailIfTryingToReturnLabelsOfDeletedNodeRest() {
    // given
    executeTransactionally("CREATE (:NodeToDelete)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (n:NodeToDelete) DELETE n RETURN labels(n)"));
    assertThat(commit).satisfies(hasErrors(Status.Statement.EntityNotFound));
    assertThat(commit.status()).isEqualTo(200);
    assertThat(nodesInDatabase()).isEqualTo(1L);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.jupiter.api.Test)

Example 80 with Response

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);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) JsonNode(org.codehaus.jackson.JsonNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Response (org.neo4j.test.server.HTTP.Response)151 Test (org.junit.Test)69 Test (org.junit.jupiter.api.Test)43 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)30 MethodSource (org.junit.jupiter.params.provider.MethodSource)30 JsonNode (com.fasterxml.jackson.databind.JsonNode)19 HTTP (org.neo4j.test.server.HTTP)13 JsonNode (org.codehaus.jackson.JsonNode)12 Node (org.neo4j.graphdb.Node)11 Transaction (org.neo4j.graphdb.Transaction)11 JsonParseException (org.neo4j.server.rest.domain.JsonParseException)6 Duration (java.time.Duration)5 ZonedDateTime (java.time.ZonedDateTime)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)3 HttpResponse (java.net.http.HttpResponse)2 HashSet (java.util.HashSet)2 Before (org.junit.Before)2 TransactionIdStore (org.neo4j.storageengine.api.TransactionIdStore)2