Search in sources :

Example 31 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
    graphdb().execute("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, containsNoErrors());
    assertThat(commit, restContainsDeletedEntities(3));
    assertThat(commit.status(), equalTo(200));
    assertThat(nodesInDatabase(), equalTo(0L));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 32 with Response

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

the class QueryResultsSerializationTest method returningADeletedPathRest.

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

Example 33 with Response

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

the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedNodeRest.

@Test
public void shouldFailIfTryingToReturnPropsOfDeletedNodeRest() {
    // given
    graphdb().execute("CREATE (:NodeToDelete {p: 'a property'})");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (n:NodeToDelete) DELETE n RETURN n.p"));
    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)

Example 34 with Response

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

the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedEntitiesRow.

@Test
public void shouldBeAbleToReturnDeletedEntitiesRow() {
    // given
    graphdb().execute("CREATE (:Start)-[:R]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (s:Start)-[r:R]->(e:End) DELETE s, r, e RETURN *"));
    assertThat(commit, containsNoErrors());
    assertThat(commit, rowContainsDeletedEntities(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 35 with Response

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

the class QueryResultsSerializationTest method shouldFailIfTryingToReturnPropsOfDeletedRelationshipRest.

@Test
public void shouldFailIfTryingToReturnPropsOfDeletedRelationshipRest() {
    // given
    graphdb().execute("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.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)

Aggregations

Response (org.neo4j.test.server.HTTP.Response)73 Test (org.junit.Test)69 JsonNode (org.codehaus.jackson.JsonNode)12 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)3 JsonParseException (org.neo4j.server.rest.domain.JsonParseException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Before (org.junit.Before)2 HTTP (org.neo4j.test.server.HTTP)2 HashSet (java.util.HashSet)1 Description (org.hamcrest.Description)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Node (org.neo4j.graphdb.Node)1 Transaction (org.neo4j.graphdb.Transaction)1 ServerControls (org.neo4j.harness.ServerControls)1 JsonHelper.jsonNode (org.neo4j.server.rest.domain.JsonHelper.jsonNode)1