use of org.neo4j.doc.server.rest.RESTDocsGenerator.ResponseEntity in project neo4j-documentation by neo4j.
the class TransactionDocIT method return_results_in_graph_format.
@Test
@Documented("Return results in graph format\n" + "\n" + "If you want to understand the graph structure of nodes and relationships returned by your query,\n" + "you can specify the \"graph\" results data format. For example, this is useful when you want to visualise the\n" + "graph structure. The format collates all the nodes and relationships from all columns of the result,\n" + "and also flattens collections of nodes and relationships, including paths.")
public void return_results_in_graph_format() throws JsonParseException {
// Document
ResponseEntity response = gen.get().noGraph().expectedStatus(200).payload(quotedJson("{'statements':[{'statement':" + "'CREATE ( bike:Bike { weight: 10 } ) " + "CREATE ( frontWheel:Wheel { spokes: 3 } ) " + "CREATE ( backWheel:Wheel { spokes: 32 } ) " + "CREATE p1 = (bike)-[:HAS { position: 1 } ]->(frontWheel) " + "CREATE p2 = (bike)-[:HAS { position: 2 } ]->(backWheel) " + "RETURN bike, p1, p2', " + "'resultDataContents': ['row','graph']}] }")).post(txCommitUri());
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertNoErrors(result);
Map<String, List<Object>> row = graphRow(result, 0);
assertEquals(3, row.get("nodes").size());
assertEquals(2, row.get("relationships").size());
}
use of org.neo4j.doc.server.rest.RESTDocsGenerator.ResponseEntity in project neo4j-documentation by neo4j.
the class RetrieveNodeDocIT method shouldGet200WhenRetrievingNodeCompact.
@Documented("Get node -- compact.\n" + "\n" + "Specifying the subformat in the requests media type yields a more compact\n" + "JSON response without metadata and templates.")
@Test
public void shouldGet200WhenRetrievingNodeCompact() {
String uri = nodeUri.toString();
ResponseEntity entity = gen.get().expectedType(CompactJsonFormat.MEDIA_TYPE).expectedStatus(200).get(uri);
assertTrue(entity.entity().contains("self"));
}
use of org.neo4j.doc.server.rest.RESTDocsGenerator.ResponseEntity in project neo4j-documentation by neo4j.
the class IndexRelationshipDocIT method create_a_unique_relationship_or_return_fail___create.
@Documented("Create a unique relationship or return fail (create).\n" + "\n" + "Here, in case\n" + "of an already existing relationship, an error should be returned. In this\n" + "example, no existing relationship is found and a new relationship is created.")
@Test
public void create_a_unique_relationship_or_return_fail___create() throws Exception {
final String index = indexes.newInstance(), key = "name", value = "Tobias";
helper.createRelationshipIndex(index);
ResponseEntity response = gen.get().noGraph().expectedStatus(201).payloadType(MediaType.APPLICATION_JSON_TYPE).payload("{\"key\": \"" + key + "\", \"value\": \"" + value + "\", \"start\": \"" + functionalTestHelper.nodeUri(helper.createNode()) + "\", \"end\": \"" + functionalTestHelper.nodeUri(helper.createNode()) + "\", \"type\":\"" + MyRelationshipTypes.KNOWS + "\"}").post(functionalTestHelper.relationshipIndexUri() + index + "?uniqueness=create_or_fail");
MultivaluedMap<String, String> headers = response.response().getHeaders();
Map<String, Object> result = JsonHelper.jsonToMap(response.entity());
assertEquals(result.get("indexed"), headers.getFirst("Location"));
}
Aggregations