Search in sources :

Example 11 with Documented

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

the class TraverserIT method shouldGetExpectedHitsWhenTraversingWithDescription.

@Documented("Traversal using a return filter.\n" + "\n" + "In this example, the +none+ prune evaluator is used and a return filter\n" + "is supplied in order to return all names containing \"t\".\n" + "The result is to be returned as nodes and the max depth is\n" + "set to 3.")
@Graph({ "Root knows Mattias", "Root knows Johan", "Johan knows Emil", "Emil knows Peter", "Emil knows Tobias", "Tobias loves Sara" })
@Test
public void shouldGetExpectedHitsWhenTraversingWithDescription() throws JsonParseException {
    Node start = getNode("Root");
    List<Map<String, Object>> rels = new ArrayList<>();
    rels.add(map("type", "knows", "direction", "all"));
    rels.add(map("type", "loves", "direction", "all"));
    String description = createJsonFrom(map("order", "breadth_first", "uniqueness", "node_global", "prune_evaluator", map("language", "javascript", "body", "position.length() > 10"), "return_filter", map("language", "javascript", "body", "position.endNode().getProperty('name').toLowerCase().contains('t')"), "relationships", rels, "max_depth", 3));
    String entity = gen().expectedStatus(200).payload(description).post(getTraverseUriNodes(start)).entity();
    expectNodes(entity, getNodes("Root", "Mattias", "Peter", "Tobias"));
}
Also used : Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) Map(java.util.Map) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 12 with Documented

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

the class RelationshipIT method shouldReturn204WhenPropertyIsRemovedFromRelationship.

@Test
@Title("Remove property from a relationship")
@Documented("See the example request below.")
@Graph(nodes = { @NODE(name = "Romeo", setNameProperty = true), @NODE(name = "Juliet", setNameProperty = true) }, relationships = { @REL(start = "Romeo", end = "Juliet", type = "LOVES", properties = { @PROP(key = "cost", value = "high", type = GraphDescription.PropType.STRING) }) })
public void shouldReturn204WhenPropertyIsRemovedFromRelationship() {
    data.get();
    Relationship loves = getFirstRelationshipFromRomeoNode();
    gen().expectedStatus(Status.NO_CONTENT.getStatusCode()).delete(getPropertiesUri(loves) + "/cost").entity();
}
Also used : Relationship(org.neo4j.graphdb.Relationship) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 13 with Documented

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

the class RetrieveNodeIT method shouldGet200WhenRetrievingNode.

@Documented("Get node.\n" + "\n" + "Note that the response contains URI/templates for the available\n" + "operations for getting properties and relationships.")
@Test
public void shouldGet200WhenRetrievingNode() throws Exception {
    String uri = nodeUri.toString();
    gen.get().expectedStatus(200).get(uri);
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 14 with Documented

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

the class PagedTraverserIT method shouldBeAbleToTraverseAllThePagesWithDefaultPageSize.

@Documented("Paging through the results of a paged traverser.\n\n" + "Paged traversers holdstate on the server, and allow clients to page through\n" + "the results of a traversal. To progress to the next page of traversal results,\n" + "the client issues a HTTP GET request on the paged traversal URI which causes the\n" + "traversal to fill the next page (or partially fill it if insufficient\n" + "results are available).\n" + " \n" + "Note that if a traverser expires through inactivity it will cause a 404\n" + "response on the next +GET+ request. Traversers' leases are renewed on\n" + "every successful access for the same amount of time as originally\n" + "specified.\n" + " \n" + "When the paged traverser reaches the end of its results, the client can\n" + "expect a 404 response as the traverser is disposed by the server.")
@Test
public void shouldBeAbleToTraverseAllThePagesWithDefaultPageSize() {
    theStartNode = createLinkedList(LONG_LIST_LENGTH, server.getDatabase());
    URI traverserLocation = createPagedTraverser().getLocation();
    int enoughPagesToExpireTheTraverser = 3;
    for (int i = 0; i < enoughPagesToExpireTheTraverser; i++) {
        gen.get().expectedType(MediaType.APPLICATION_JSON_TYPE).expectedStatus(200).payload(traverserDescription()).get(traverserLocation.toString());
    }
    JaxRsResponse response = new RestRequest(traverserLocation).get();
    assertEquals(404, response.getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) URI(java.net.URI) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 15 with Documented

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

the class PagedTraverserIT method shouldExpireTraverserWithNonDefaultTimeout.

@Documented("Paged traverser timeout.\n\n" + "The default timeout for a paged traverser is 60\n" + "seconds, but depending on the application larger or smaller timeouts\n" + "might be appropriate. This can be set by adding a +leaseTime+ query\n" + "parameter with the number of seconds the paged traverser should last.")
@Test
public void shouldExpireTraverserWithNonDefaultTimeout() {
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    URI traverserLocation = createPagedTraverserWithTimeoutInMinutes(10).getLocation();
    clock.forward(11, TimeUnit.MINUTES);
    JaxRsResponse response = new RestRequest(traverserLocation).get();
    assertEquals(404, response.getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) URI(java.net.URI) 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