use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class PluginFunctionalTestHelper method makePostMap.
protected static Map<String, Object> makePostMap(String url, Map<String, Object> params) throws JsonParseException {
String json = JsonHelper.createJsonFrom(params);
JaxRsResponse response = new RestRequest().post(url, json, MediaType.APPLICATION_JSON_TYPE);
String body = getResponseText(response);
response.close();
return deserializeMap(body);
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class CloneSubgraphPluginTest method shouldAdvertiseExtenstionThatPluginCreates.
@Test
public void shouldAdvertiseExtenstionThatPluginCreates() throws JsonParseException, ClientHandlerException, UniformInterfaceException {
int originalCount = nodeCount();
// Find the start node URI from the server
JaxRsResponse response = new RestRequest().get(functionalTestHelper.dataUri() + "node/1");
String entity = response.getEntity();
Map<String, Object> map = JsonHelper.jsonToMap(entity);
HashMap<?, ?> extensionsMap = (HashMap<?, ?>) map.get("extensions");
assertNotNull(extensionsMap);
assertFalse(extensionsMap.isEmpty());
final String GRAPH_CLONER_KEY = "GraphCloner";
assertTrue(extensionsMap.keySet().contains(GRAPH_CLONER_KEY));
final String CLONE_SUBGRAPH_KEY = "clonedSubgraph";
String clonedSubgraphUri = (String) ((HashMap<?, ?>) extensionsMap.get(GRAPH_CLONER_KEY)).get(CLONE_SUBGRAPH_KEY);
assertNotNull(clonedSubgraphUri);
final String CLONE_DEPTH_MUCH_LARGER_THAN_THE_GRAPH = "99";
response.close();
response = new RestRequest().post(clonedSubgraphUri, "depth=" + CLONE_DEPTH_MUCH_LARGER_THAN_THE_GRAPH, MediaType.APPLICATION_FORM_URLENCODED_TYPE);
Assert.assertEquals(response.getEntity(), 200, response.getStatus());
int doubleTheNumberOfNodes = originalCount * 2;
assertEquals(doubleTheNumberOfNodes, nodeCount());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class ExtensionListingFunctionalTest method canListExtensionMethodsForServerExtension.
@SuppressWarnings("unchecked")
@Test
public void canListExtensionMethodsForServerExtension() throws Exception {
JaxRsResponse response = RestRequest.req().get(functionalTestHelper.extensionUri());
assertThat(response.getStatus(), equalTo(200));
Map<String, Object> json = JsonHelper.jsonToMap(response.getEntity());
String refNodeService = (String) json.get(FunctionalTestPlugin.class.getSimpleName());
response.close();
response = RestRequest.req().get(refNodeService);
String result = response.getEntity();
assertThat(response.getStatus(), equalTo(200));
json = JsonHelper.jsonToMap(result);
json = (Map<String, Object>) json.get("graphdb");
assertThat(json, hasKey(FunctionalTestPlugin.CREATE_NODE));
response.close();
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class ExtensionListingFunctionalTest method canListAllAvailableServerExtensions.
@Test
public void canListAllAvailableServerExtensions() throws Exception {
JaxRsResponse response = RestRequest.req().get(functionalTestHelper.extensionUri());
assertThat(response.getStatus(), equalTo(200));
Map<String, Object> json = JsonHelper.jsonToMap(response.getEntity());
assertFalse(json.isEmpty());
response.close();
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class ExtensionListingFunctionalTest method datarootContainsReferenceToExtensions.
@Test
public void datarootContainsReferenceToExtensions() throws Exception {
JaxRsResponse response = RestRequest.req().get(functionalTestHelper.dataUri());
assertThat(response.getStatus(), equalTo(200));
Map<String, Object> json = JsonHelper.jsonToMap(response.getEntity());
String extInfo = (String) json.get("extensions_info");
assertNotNull(new URI(extInfo));
response.close();
}
Aggregations