Search in sources :

Example 96 with Response

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

the class QueryResultsSerializationTest method shouldNotMarkNormalEntitiesAsDeletedGraph.

@Test
public void shouldNotMarkNormalEntitiesAsDeletedGraph() {
    // given
    graphdb().execute("CREATE (:Start)-[:R]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (s:Start)-[r:R]->(e:End) RETURN *"));
    assertThat(commit, containsNoErrors());
    assertThat(commit, graphContainsNoDeletedEntities());
    assertThat(commit.status(), equalTo(200));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 97 with Response

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

the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedEntitiesGraph.

@Test
public void shouldBeAbleToReturnDeletedEntitiesGraph() {
    // given
    graphdb().execute("CREATE (:Start)-[:R]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (s:Start)-[r:R]->(e:End) DELETE s, r, e RETURN *"));
    assertThat(commit, containsNoErrors());
    assertThat(commit, graphContainsDeletedRelationships(1));
    assertThat(commit, graphContainsDeletedNodes(2));
    assertThat(commit.status(), equalTo(200));
    assertThat(nodesInDatabase(), equalTo(0L));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 98 with Response

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

the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedRelationshipRow.

@Test
public void shouldFailIfTryingToReturnPropsOfDeletedRelationshipRow() {
    // given
    graphdb().execute("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.p"));
    assertThat(commit, hasErrors(Status.Statement.EntityNotFound));
    assertThat(commit.status(), equalTo(200));
    assertThat(nodesInDatabase(), equalTo(2L));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 99 with Response

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

the class QueryResultsSerializationTest method returningADeletedPathRow.

@Test
public void returningADeletedPathRow() {
    // given
    graphdb().execute("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, containsNoErrors());
    assertThat(commit, rowContainsDeletedEntitiesInPath(2, 1));
    assertThat(commit.status(), equalTo(200));
    assertThat(nodesInDatabase(), equalTo(0L));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 100 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
    graphdb().execute("CREATE (:NodeToDelete)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (n:NodeToDelete) DELETE n RETURN labels(n)"));
    assertThat(commit, hasErrors(Status.Statement.EntityNotFound));
    assertThat(commit.status(), equalTo(200));
    assertThat(nodesInDatabase(), equalTo(1L));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) 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