Search in sources :

Example 91 with Response

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

the class TransactionIT method begin_and_execute_multiple_periodic_commit_last_and_commit.

@Test
public void begin_and_execute_multiple_periodic_commit_last_and_commit() throws Exception {
    ServerTestUtils.withCSVFile(1, url -> {
        Response response = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'CREATE ()' }, " + "{ 'statement': 'USING PERIODIC COMMIT LOAD CSV FROM \\\"" + url + "\\\" AS line " + "CREATE ()' } ] }"));
        assertThat(response, hasErrors(Status.Statement.SemanticError));
    });
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 92 with Response

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

the class TransactionIT method should_serialize_collect_correctly.

@Test
public void should_serialize_collect_correctly() throws Exception {
    // given
    http.POST("/db/data/transaction/commit", singleStatement("CREATE (n:Foo)"));
    // when
    Response response = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'MATCH (n:Foo) RETURN COLLECT(n)' } ] }"));
    // then
    assertThat(response.status(), equalTo(200));
    JsonNode data = response.get("results").get(0);
    assertThat(data.get("columns").get(0).asText(), equalTo("COLLECT(n)"));
    assertThat(data.get("data").get(0).get("row").size(), equalTo(1));
    assertThat(data.get("data").get(0).get("row").get(0).get(0).size(), equalTo(0));
    assertThat(response.get("errors").size(), equalTo(0));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) JsonNode(org.codehaus.jackson.JsonNode) Test(org.junit.Test)

Example 93 with Response

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

the class TransactionIT method begin_and_execute_invalid_query_and_commit.

@Test
public void begin_and_execute_invalid_query_and_commit() throws Exception {
    // begin and execute and commit
    Response response = http.POST("/db/data/transaction/commit", quotedJson("{ 'statements': [ { 'statement': 'MATCH n RETURN m' } ] }"));
    assertThat(response.status(), equalTo(200));
    assertThat(response, hasErrors(Status.Statement.SyntaxError));
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.Test)

Example 94 with Response

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

the class QueryResultsSerializationTest method returningAPartiallyDeletedPathRow.

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

Example 95 with Response

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

the class QueryResultsSerializationTest method nestedShouldWorkGraph.

@Test
public void nestedShouldWorkGraph() {
    // given
    graphdb().execute("CREATE ()");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (n) DELETE (n) RETURN [n, {someKey: n}]"));
    assertThat(commit, containsNoErrors());
    assertThat(commit.status(), equalTo(200));
    assertThat(commit, graphContainsDeletedNodes(1));
    assertThat(nodesInDatabase(), equalTo(0L));
}
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