use of org.codehaus.jackson.node.ArrayNode in project activityinfo by bedatadriven.
the class SitesResourcesTest method indicatorsArePresent.
@Test
public void indicatorsArePresent() throws IOException {
QueryParameters parameters = new QueryParameters();
parameters.databaseIds.add(2);
String json = query(parameters);
System.out.println(json);
ObjectMapper mapper = new ObjectMapper();
JsonFactory factory = mapper.getJsonFactory();
JsonParser jp = factory.createJsonParser(json);
ArrayNode array = (ArrayNode) mapper.readTree(jp);
assertThat(array.size(), equalTo(3));
JsonNode site6 = getSiteById(array, 6);
assertThat(site6.path("id").asInt(), equalTo(6));
assertThat(site6.path("activity").asInt(), equalTo(4));
double indicatorValue = site6.path("indicatorValues").path("6").asDouble();
assertThat(indicatorValue, equalTo(70d));
}
use of org.codehaus.jackson.node.ArrayNode in project neo4j-documentation by neo4j.
the class EnterpriseAuthenticationDocIT method shouldAllowExecutingEnterpriseBuiltInProceduresWithAuthDisabled.
@Test
public void shouldAllowExecutingEnterpriseBuiltInProceduresWithAuthDisabled() throws Exception {
// Given
startServerWithAuthDisabled();
// When
String method = "POST";
String path = "db/data/transaction/commit";
HTTP.RawPayload payload = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.listQueries()'}]}");
HTTP.Response response = HTTP.request(method, server.baseUri().resolve(path).toString(), payload);
// Then
assertThat(response.status(), equalTo(200));
ArrayNode errors = (ArrayNode) response.get("errors");
assertThat("Should have no errors", errors.size(), equalTo(0));
ArrayNode results = (ArrayNode) response.get("results");
ArrayNode data = (ArrayNode) results.get(0).get("data");
assertThat("Should see our own query", data.size(), equalTo(1));
}
use of org.codehaus.jackson.node.ArrayNode in project helix by apache.
the class WorkflowAccessor method getWorkflow.
@GET
@Path("{workflowId}")
public Response getWorkflow(@PathParam("clusterId") String clusterId, @PathParam("workflowId") String workflowId) {
TaskDriver taskDriver = getTaskDriver(clusterId);
WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflowId);
WorkflowContext workflowContext = taskDriver.getWorkflowContext(workflowId);
ObjectNode root = JsonNodeFactory.instance.objectNode();
TextNode id = JsonNodeFactory.instance.textNode(workflowId);
root.put(Properties.id.name(), id);
ObjectNode workflowConfigNode = JsonNodeFactory.instance.objectNode();
ObjectNode workflowContextNode = JsonNodeFactory.instance.objectNode();
if (workflowConfig != null) {
getWorkflowConfigNode(workflowConfigNode, workflowConfig.getRecord());
}
if (workflowContext != null) {
getWorkflowContextNode(workflowContextNode, workflowContext.getRecord());
}
root.put(WorkflowProperties.WorkflowConfig.name(), workflowConfigNode);
root.put(WorkflowProperties.WorkflowContext.name(), workflowContextNode);
JobDag jobDag = workflowConfig.getJobDag();
ArrayNode jobs = OBJECT_MAPPER.valueToTree(jobDag.getAllNodes());
ObjectNode parentJobs = OBJECT_MAPPER.valueToTree(jobDag.getChildrenToParents());
root.put(WorkflowProperties.Jobs.name(), jobs);
root.put(WorkflowProperties.ParentJobs.name(), parentJobs);
return JSONRepresentation(root);
}
use of org.codehaus.jackson.node.ArrayNode in project helix by apache.
the class InstanceAccessor method getInstances.
@GET
public Response getInstances(@PathParam("clusterId") String clusterId) {
HelixDataAccessor accessor = getDataAccssor(clusterId);
ObjectNode root = JsonNodeFactory.instance.objectNode();
root.put(Properties.id.name(), JsonNodeFactory.instance.textNode(clusterId));
ArrayNode instancesNode = root.putArray(InstanceProperties.instances.name());
ArrayNode onlineNode = root.putArray(InstanceProperties.online.name());
ArrayNode disabledNode = root.putArray(InstanceProperties.disabled.name());
List<String> instances = accessor.getChildNames(accessor.keyBuilder().instanceConfigs());
if (instances != null) {
instancesNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(instances));
} else {
return notFound();
}
List<String> liveInstances = accessor.getChildNames(accessor.keyBuilder().liveInstances());
ClusterConfig clusterConfig = accessor.getProperty(accessor.keyBuilder().clusterConfig());
for (String instanceName : instances) {
InstanceConfig instanceConfig = accessor.getProperty(accessor.keyBuilder().instanceConfig(instanceName));
if (instanceConfig != null) {
if (!instanceConfig.getInstanceEnabled() || (clusterConfig.getDisabledInstances() != null && clusterConfig.getDisabledInstances().containsKey(instanceName))) {
disabledNode.add(JsonNodeFactory.instance.textNode(instanceName));
}
if (liveInstances.contains(instanceName)) {
onlineNode.add(JsonNodeFactory.instance.textNode(instanceName));
}
}
}
return JSONRepresentation(root);
}
use of org.codehaus.jackson.node.ArrayNode in project helix by apache.
the class JobAccessor method getJobs.
@GET
public Response getJobs(@PathParam("clusterId") String clusterId, @PathParam("workflowName") String workflowName) {
TaskDriver driver = getTaskDriver(clusterId);
WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflowName);
ObjectNode root = JsonNodeFactory.instance.objectNode();
if (workflowConfig == null) {
return badRequest(String.format("Workflow %s is not found!", workflowName));
}
Set<String> jobs = workflowConfig.getJobDag().getAllNodes();
root.put(Properties.id.name(), JobProperties.Jobs.name());
ArrayNode jobsNode = root.putArray(JobProperties.Jobs.name());
if (jobs != null) {
jobsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(jobs));
}
return JSONRepresentation(root);
}
Aggregations