Search in sources :

Example 26 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.

the class TestLog4Json method assertEntryEquals.

void assertEntryEquals(ContainerNode rootNode, String key, String value) {
    JsonNode node = assertNodeContains(rootNode, key);
    assertEquals(value, node.textValue());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 27 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.

the class TestLog4Json method assertEntryEquals.

void assertEntryEquals(ContainerNode rootNode, String key, long value) {
    JsonNode node = assertNodeContains(rootNode, key);
    assertEquals(value, node.numberValue());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 28 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.

the class JHEventHandlerForSigtermTest method testCountersToJSONEmpty.

@Test(timeout = 50000)
public void testCountersToJSONEmpty() throws Exception {
    JobHistoryEventHandler jheh = new JobHistoryEventHandler(null, 0);
    Counters counters = null;
    JsonNode jsonNode = JobHistoryEventUtils.countersToJSON(counters);
    String jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
    String expected = "[]";
    Assert.assertEquals(expected, jsonStr);
    counters = new Counters();
    jsonNode = JobHistoryEventUtils.countersToJSON(counters);
    jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
    expected = "[]";
    Assert.assertEquals(expected, jsonStr);
    counters.addGroup("DOCTORS", "Incarnations of the Doctor");
    jsonNode = JobHistoryEventUtils.countersToJSON(counters);
    jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
    expected = "[{\"NAME\":\"DOCTORS\",\"DISPLAY_NAME\":\"Incarnations of the " + "Doctor\",\"COUNTERS\":[]}]";
    Assert.assertEquals(expected, jsonStr);
}
Also used : Counters(org.apache.hadoop.mapreduce.Counters) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 29 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.

the class JHEventHandlerForSigtermTest method testCountersToJSON.

@Test(timeout = 50000)
public void testCountersToJSON() throws Exception {
    JobHistoryEventHandler jheh = new JobHistoryEventHandler(null, 0);
    Counters counters = new Counters();
    CounterGroup group1 = counters.addGroup("DOCTORS", "Incarnations of the Doctor");
    group1.addCounter("PETER_CAPALDI", "Peter Capaldi", 12);
    group1.addCounter("MATT_SMITH", "Matt Smith", 11);
    group1.addCounter("DAVID_TENNANT", "David Tennant", 10);
    CounterGroup group2 = counters.addGroup("COMPANIONS", "Companions of the Doctor");
    group2.addCounter("CLARA_OSWALD", "Clara Oswald", 6);
    group2.addCounter("RORY_WILLIAMS", "Rory Williams", 5);
    group2.addCounter("AMY_POND", "Amy Pond", 4);
    group2.addCounter("MARTHA_JONES", "Martha Jones", 3);
    group2.addCounter("DONNA_NOBLE", "Donna Noble", 2);
    group2.addCounter("ROSE_TYLER", "Rose Tyler", 1);
    JsonNode jsonNode = JobHistoryEventUtils.countersToJSON(counters);
    String jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
    String expected = "[{\"NAME\":\"COMPANIONS\",\"DISPLAY_NAME\":\"Companions " + "of the Doctor\",\"COUNTERS\":[{\"NAME\":\"AMY_POND\",\"DISPLAY_NAME\"" + ":\"Amy Pond\",\"VALUE\":4},{\"NAME\":\"CLARA_OSWALD\"," + "\"DISPLAY_NAME\":\"Clara Oswald\",\"VALUE\":6},{\"NAME\":" + "\"DONNA_NOBLE\",\"DISPLAY_NAME\":\"Donna Noble\",\"VALUE\":2}," + "{\"NAME\":\"MARTHA_JONES\",\"DISPLAY_NAME\":\"Martha Jones\"," + "\"VALUE\":3},{\"NAME\":\"RORY_WILLIAMS\",\"DISPLAY_NAME\":\"Rory " + "Williams\",\"VALUE\":5},{\"NAME\":\"ROSE_TYLER\",\"DISPLAY_NAME\":" + "\"Rose Tyler\",\"VALUE\":1}]},{\"NAME\":\"DOCTORS\",\"DISPLAY_NAME\"" + ":\"Incarnations of the Doctor\",\"COUNTERS\":[{\"NAME\":" + "\"DAVID_TENNANT\",\"DISPLAY_NAME\":\"David Tennant\",\"VALUE\":10}," + "{\"NAME\":\"MATT_SMITH\",\"DISPLAY_NAME\":\"Matt Smith\",\"VALUE\":" + "11},{\"NAME\":\"PETER_CAPALDI\",\"DISPLAY_NAME\":\"Peter Capaldi\"," + "\"VALUE\":12}]}]";
    Assert.assertEquals(expected, jsonStr);
}
Also used : CounterGroup(org.apache.hadoop.mapreduce.CounterGroup) Counters(org.apache.hadoop.mapreduce.Counters) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 30 with JsonNode

use of com.fasterxml.jackson.databind.JsonNode in project kafka by apache.

the class JsonConverterTest method arrayToJson.

@Test
public void arrayToJson() {
    Schema int32Array = SchemaBuilder.array(Schema.INT32_SCHEMA).build();
    JsonNode converted = parse(converter.fromConnectData(TOPIC, int32Array, Arrays.asList(1, 2, 3)));
    validateEnvelope(converted);
    assertEquals(parse("{ \"type\": \"array\", \"items\": { \"type\": \"int32\", \"optional\": false }, \"optional\": false }"), converted.get(JsonSchema.ENVELOPE_SCHEMA_FIELD_NAME));
    assertEquals(JsonNodeFactory.instance.arrayNode().add(1).add(2).add(3), converted.get(JsonSchema.ENVELOPE_PAYLOAD_FIELD_NAME));
}
Also used : Schema(org.apache.kafka.connect.data.Schema) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)879 Test (org.junit.Test)224 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)217 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)142 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)125 IOException (java.io.IOException)91 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)86 HashMap (java.util.HashMap)79 HttpGet (org.apache.http.client.methods.HttpGet)68 JsonException (jmri.server.json.JsonException)66 Deployment (org.activiti.engine.test.Deployment)66 ArrayList (java.util.ArrayList)62 InputStream (java.io.InputStream)55 StringEntity (org.apache.http.entity.StringEntity)54 ByteArrayInputStream (java.io.ByteArrayInputStream)51 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)49 Task (org.activiti.engine.task.Task)41 HttpPost (org.apache.http.client.methods.HttpPost)39 Map (java.util.Map)33 Tree (org.apache.jackrabbit.oak.api.Tree)30