Search in sources :

Example 56 with Response

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

the class QueryResultsSerializationTest method returningADeletedPathGraph.

@Test
public void returningADeletedPathGraph() {
    // given
    executeTransactionally("CREATE (:Start)-[:R]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH p=(s)-[r:R]->(e) DELETE p RETURN p"));
    assertThat(commit).satisfies(containsNoErrors());
    assertThat(commit).satisfies(graphContainsDeletedNodes(2));
    assertThat(commit).satisfies(graphContainsDeletedRelationships(1));
    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 57 with Response

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

the class QueryResultsSerializationTest method shouldBeAbleToReturnDeletedRelationshipsGraph.

@Test
public void shouldBeAbleToReturnDeletedRelationshipsGraph() {
    // given
    executeTransactionally("CREATE (:Start)-[:R {p: 'a property'}]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonGraph("MATCH (s)-[r:R]->(e) DELETE r RETURN r"));
    assertThat(commit).satisfies(containsNoErrors());
    assertThat(commit).satisfies(graphContainsDeletedRelationships(1));
    assertThat(commit.status()).isEqualTo(200);
    assertThat(nodesInDatabase()).isEqualTo(2L);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.jupiter.api.Test)

Example 58 with Response

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

the class RowFormatMetaFieldTestIT method metaFieldShouldGivePathInfoInList.

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

Example 59 with Response

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

the class TransactionIT method begin__execute__execute__commit.

@ParameterizedTest
@MethodSource("argumentsProvider")
public void begin__execute__execute__commit(String txUri) throws Exception {
    this.txUri = txUri;
    long nodesInDatabaseBeforeTransaction = countNodes();
    // begin
    Response begin = POST(txUri);
    String commitResource = begin.stringFromContent("commit");
    // execute
    POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
    // execute
    POST(begin.location(), quotedJson("{ 'statements': [ { 'statement': 'CREATE (n)' } ] }"));
    // commit
    POST(commitResource);
    assertThat(countNodes()).isEqualTo(nodesInDatabaseBeforeTransaction + 2);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 60 with Response

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

the class TransactionIT method begin_and_execute_periodic_commit_followed_by_another_statement_and_commit.

@ParameterizedTest
@MethodSource("argumentsProvider")
public void begin_and_execute_periodic_commit_followed_by_another_statement_and_commit(String txUri) throws Exception {
    this.txUri = txUri;
    withCSVFile(1, url -> {
        // begin and execute and commit
        Response response = POST(transactionCommitUri(), quotedJson("{ 'statements': [ { 'statement': 'USING PERIODIC COMMIT LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE (n {id: 23}) RETURN n' }, { 'statement': 'RETURN 1' } ] }"));
        assertThat(response.status()).isEqualTo(200);
        assertThat(response).satisfies(hasErrors(Status.Statement.SemanticError));
    });
}
Also used : Response(org.neo4j.test.server.HTTP.Response) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

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