Search in sources :

Example 51 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class CypherIT method send_query_to_create_a_node.

@Test
@Documented("Create a node with a label and a property using Cypher. See the request for the parameter " + "sent with the query.")
@Title("Create a node")
@Graph
public void send_query_to_create_a_node() throws Exception {
    data.get();
    String script = "CREATE (n:Person { name : {name} }) RETURN n";
    String response = cypherRestCall(script, Status.OK, Pair.of("name", "Andres"));
    assertTrue(response.contains("name"));
    assertTrue(response.contains("Andres"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 52 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class CypherIT method send_query_to_create_a_node_from_a_map.

@Test
@Title("Create a node with multiple properties")
@Documented("Create a node with a label and multiple properties using Cypher. See the request for the parameter " + "sent with the query.")
@Graph
public void send_query_to_create_a_node_from_a_map() throws Exception {
    data.get();
    String script = "CREATE (n:Person { props } ) RETURN n";
    String params = "\"props\" : { \"position\" : \"Developer\", \"name\" : \"Michael\", \"awesome\" : true, \"children\" : 3 }";
    String response = cypherRestCall(script, Status.OK, params);
    assertTrue(response.contains("name"));
    assertTrue(response.contains("Michael"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 53 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class DatabaseMetadataServiceIT method shouldReturn200OnGet.

@Documented("Get relationship types.")
@Test
public void shouldReturn200OnGet() {
    helper.createRelationship("KNOWS");
    helper.createRelationship("LOVES");
    String result = gen.get().expectedStatus(200).get(functionalTestHelper.dataUri() + "relationship/types").entity();
    assertThat(result, allOf(containsString("KNOWS"), containsString("LOVES")));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 54 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class GetNodePropertiesIT method shouldGet200ForProperty.

@Documented("Get property for node.\n" + "\n" + "Get a single node property from a node.")
@Test
public void shouldGet200ForProperty() throws JsonParseException {
    String entity = JsonHelper.createJsonFrom(Collections.singletonMap("foo", "bar"));
    JaxRsResponse createResponse = req.post(functionalTestHelper.dataUri() + "node/", entity);
    JaxRsResponse response = req.get(getPropertyUri(createResponse.getLocation().toString(), "foo"));
    assertEquals(200, response.getStatus());
    gen.get().expectedStatus(200).get(getPropertyUri(createResponse.getLocation().toString(), "foo"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 55 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class GetOnRootIT method streaming.

@Documented("All responses from the REST API can be transmitted as JSON streams, resulting in\n" + "better performance and lower memory overhead on the server side. To use\n" + "streaming, supply the header `X-Stream: true` with each request.")
@Test
public void streaming() throws Exception {
    data.get();
    ResponseEntity responseEntity = gen().withHeader(StreamingFormat.STREAM_HEADER, "true").expectedType(APPLICATION_JSON_TYPE).expectedStatus(200).get(getDataUri());
    JaxRsResponse response = responseEntity.response();
    // this gets the full media type, including things like
    // ; stream=true at the end
    String foundMediaType = response.getType().toString();
    String expectedMediaType = StreamingFormat.MEDIA_TYPE.toString();
    assertEquals(expectedMediaType, foundMediaType);
    String body = responseEntity.entity();
    Map<String, Object> map = JsonHelper.jsonToMap(body);
    assertEquals(getDataUri() + "node", map.get("node"));
}
Also used : ResponseEntity(org.neo4j.server.rest.RESTRequestGenerator.ResponseEntity) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Aggregations

Documented (org.neo4j.kernel.impl.annotations.Documented)71 Test (org.junit.Test)70 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)26 Graph (org.neo4j.test.GraphDescription.Graph)21 ResponseEntity (org.neo4j.server.rest.RESTRequestGenerator.ResponseEntity)20 Title (org.neo4j.test.TestData.Title)19 Node (org.neo4j.graphdb.Node)14 Matchers.containsString (org.hamcrest.Matchers.containsString)11 Transaction (org.neo4j.graphdb.Transaction)8 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)7 JsonNode (org.codehaus.jackson.JsonNode)6 JaxRsResponse (org.neo4j.server.rest.JaxRsResponse)6 RESTRequestGenerator (org.neo4j.server.rest.RESTRequestGenerator)6 ArrayList (java.util.ArrayList)5 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)5 Relationship (org.neo4j.graphdb.Relationship)5 Map (java.util.Map)4 URI (java.net.URI)3 FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)3 RestRequest (org.neo4j.server.rest.RestRequest)3