Search in sources :

Example 71 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
    executeTransactionally("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).satisfies(hasErrors(Status.Statement.EntityNotFound));
    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 72 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
    executeTransactionally("CREATE (:Start)-[:MARKER {p: 'a property'}]->(:End)");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRest("MATCH (s)-[r:MARKER]->(e) DELETE r RETURN r.p"));
    assertThat(commit).as("Error raw response: " + commit.rawContent()).satisfies(hasErrors(Status.Statement.EntityNotFound));
    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 73 with Response

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

the class QueryResultsSerializationTest method returningAPartiallyDeletedPathGraph.

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

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

the class QueryResultsSerializationTest method nestedShouldWorkRow.

@Test
public void nestedShouldWorkRow() {
    // given
    executeTransactionally("CREATE ()");
    // execute and commit
    Response commit = http.POST(commitResource, queryAsJsonRow("MATCH (n) DELETE (n) RETURN [n, {someKey: n}]"));
    assertThat(commit).satisfies(containsNoErrors());
    assertThat(commit.status()).isEqualTo(200);
    assertThat(commit).satisfies(rowContainsDeletedEntities(2, 0));
    assertThat(nodesInDatabase()).isEqualTo(0L);
}
Also used : Response(org.neo4j.test.server.HTTP.Response) Test(org.junit.jupiter.api.Test)

Example 75 with Response

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

the class QueryResultsSerializationTest method shouldHandleTemporalArraysUsingGraphResultDataContent.

@Test
public void shouldHandleTemporalArraysUsingGraphResultDataContent() throws Exception {
    // Given
    var db = getDefaultDatabase();
    ZonedDateTime date = ZonedDateTime.of(1980, 3, 11, 0, 0, 0, 0, ZoneId.of("Europe/Stockholm"));
    try (Transaction tx = db.beginTx()) {
        Node node = tx.createNode(label("N"));
        node.setProperty("dates", new ZonedDateTime[] { date });
        tx.commit();
    }
    // When
    HTTP.Response response = runQuery("MATCH (n:N) RETURN n", "graph");
    // Then
    assertEquals(200, response.status());
    assertNoErrors(response);
    JsonNode row = response.get("results").get(0).get("data").get(0).get("graph").get("nodes").get(0).get("properties").get("dates").get(0);
    assertEquals("\"1980-03-11T00:00+01:00[Europe/Stockholm]\"", row.toString());
}
Also used : Transaction(org.neo4j.graphdb.Transaction) ZonedDateTime(java.time.ZonedDateTime) Node(org.neo4j.graphdb.Node) JsonNode(com.fasterxml.jackson.databind.JsonNode) Response(org.neo4j.test.server.HTTP.Response) HTTP(org.neo4j.test.server.HTTP) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.jupiter.api.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