Example usage for com.fasterxml.jackson.databind.node JsonNodeFactory instance

List of usage examples for com.fasterxml.jackson.databind.node JsonNodeFactory instance

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node JsonNodeFactory instance.

Prototype

JsonNodeFactory instance

To view the source code for com.fasterxml.jackson.databind.node JsonNodeFactory instance.

Click Source Link

Usage

From source file:controllers.MetaController.java

/**
 * Endpoint implementation to retrieve service health as JSON.
 *
 * @return Serialized response containing service health.
 */// w w w . j  a  v a2s .c  o m
public Result ping() {
    final boolean healthy = isHealthy();
    final ObjectNode result = JsonNodeFactory.instance.objectNode();
    response().setHeader(CACHE_CONTROL, "private, no-cache, no-store, must-revalidate");
    if (healthy) {
        result.put("status", HEALTHY_STATE);
        return ok(result);
    }
    result.put("status", UNHEALTHY_STATE);
    return internalServerError(result);
}

From source file:org.eel.kitchen.jsonschema.ref.SchemaRegistryTest.java

@Test
public void namespacesAreRespected() throws IOException, JsonSchemaException {
    final URI fullPath = URI.create("foo:/baz#");
    final URIManager manager = new URIManager();
    final URIDownloader downloader = spy(new URIDownloader() {
        @Override//from  ww w . j  a va2s .c  o m
        public InputStream fetch(final URI source) throws IOException {
            if (!fullPath.equals(source))
                throw new IOException();
            return new ByteArrayInputStream(JsonNodeFactory.instance.objectNode().toString().getBytes());
        }
    });
    manager.registerScheme("foo", downloader);

    final URI rootns = URI.create("foo:///bar/../bar/");

    final SchemaRegistry registry = new SchemaRegistry(manager, rootns);

    final URI uri = URI.create("../baz");
    registry.get(uri);
    final JsonRef ref = JsonRef.fromURI(rootns.resolve(uri));
    verify(downloader).fetch(rootns.resolve(ref.toURI()));
}

From source file:org.apache.taverna.gis.GisActivityTest.java

@Before
public void makeConfiguration() throws Exception {
    configuration = JsonNodeFactory.instance.objectNode();
    configuration.put("exampleString", "something");
    configuration.put("exampleUri", "http://localhost:8080/myEndPoint");
}

From source file:net.sf.taverna.t2.activities.soaplab.SoaplabActivityTest.java

@Ignore("Integration test")
@Before/*  ww  w .ja  v a 2  s .  c om*/
public void setUp() throws Exception {
    activity = new SoaplabActivity();
    configurationBean = JsonNodeFactory.instance.objectNode();
    configurationBean.put("endpoint", "http://www.ebi.ac.uk/soaplab/emboss4/services/utils_misc.embossversion");
}

From source file:org.eel.kitchen.jsonschema.validator.ObjectValidatorTest.java

private static void checkNodeAndPaths(final Set<JsonNode> actual, final JsonNode expected) {
    assertEquals(actual.size(), expected.size());

    final Set<JsonNode> expectedSet = ImmutableSet.copyOf(expected);
    final Set<JsonNode> actualSet = Sets.newHashSet();

    Map<String, JsonNode> map;
    ObjectNode node;//from   w  w  w .  java 2  s.  c  o  m

    for (final JsonNode element : actual) {
        node = JsonNodeFactory.instance.objectNode();
        map = JacksonUtils.nodeToMap(element);
        node.putAll(map);
        actualSet.add(node);
    }

    assertEqualsNoOrder(actualSet.toArray(), expectedSet.toArray());
}

From source file:com.digitalpebble.storm.crawler.filtering.BasicURLNormalizerTest.java

private URLFilter createFilter(boolean removeAnchor) {
    ObjectNode filterParams = new ObjectNode(JsonNodeFactory.instance);
    filterParams.put("removeAnchorPart", Boolean.valueOf(removeAnchor));
    return createFilter(filterParams);
}

From source file:com.axelor.web.MapRest.java

@Path("/geomap/turnover")
@GET/* w  w  w. j a  va  2s  .  co m*/
@Produces(MediaType.APPLICATION_JSON)
public JsonNode getGeoMapData() {

    Map<String, BigDecimal> data = new HashMap<String, BigDecimal>();
    List<? extends SaleOrder> orders = saleOrderRepo.all().filter("self.statusSelect=?", 3).fetch();
    JsonNodeFactory factory = JsonNodeFactory.instance;
    ObjectNode mainNode = factory.objectNode();
    ArrayNode arrayNode = factory.arrayNode();

    ArrayNode labelNode = factory.arrayNode();
    labelNode.add("Country");
    labelNode.add("Turnover");
    arrayNode.add(labelNode);

    for (SaleOrder so : orders) {

        Country country = so.getMainInvoicingAddress().getAddressL7Country();
        BigDecimal value = so.getExTaxTotal();

        if (country != null) {
            String key = country.getName();

            if (data.containsKey(key)) {
                BigDecimal oldValue = data.get(key);
                oldValue = oldValue.add(value);
                data.put(key, oldValue);
            } else {
                data.put(key, value);
            }
        }
    }

    Iterator<String> keys = data.keySet().iterator();
    while (keys.hasNext()) {
        String key = keys.next();
        ArrayNode dataNode = factory.arrayNode();
        dataNode.add(key);
        dataNode.add(data.get(key));
        arrayNode.add(dataNode);
    }

    mainNode.put("status", 0);
    mainNode.put("data", arrayNode);
    return mainNode;
}

From source file:org.apache.solr.kelvin.responseanalyzers.XmlDoclistExtractorResponseAnalyzerTest.java

public static Map<String, Object> quickParseForTest(String resName) throws Exception {
    Map<String, Object> previousResponses = new HashMap<String, Object>();
    JsonNode emptyConf = JsonNodeFactory.instance.objectNode();
    XmlResponseAnalyzer ra_xml = new XmlResponseAnalyzer();
    ra_xml.configure(emptyConf);/*  w  w  w .j ava 2s . co m*/
    XmlDoclistExtractorResponseAnalyzer ra = new XmlDoclistExtractorResponseAnalyzer();
    ra.configure(emptyConf); //empty conf

    previousResponses.put(QueryPerformer.RAW_RESPONSE,
            IOUtils.toString(XmlResponseAnalyzerTest.class.getResourceAsStream(resName), "utf8"));
    try {
        ra_xml.decode(previousResponses);
    } catch (Exception e) {
        //its ok to skip, the class must works also in case of errors
    }
    ra.decode(previousResponses);
    return previousResponses;
}

From source file:com.meltmedia.dropwizard.crypto.JsonPointerEditorTest.java

@Test
public void shouldSetValue() throws Exception {
    JsonNode node = mapper.readValue("{\"key\": {\"sub\": \"value\"}}", JsonNode.class);
    JsonPointer pointer = JsonPointer.compile("/key/sub");

    JsonPointerEditor editor = new JsonPointerEditor(node, pointer);
    editor.setValue(JsonNodeFactory.instance.textNode("updated"));
    assertThat("updated", equalTo(editor.getValue().asText()));
}

From source file:com.nebhale.jsonpath.internal.component.ChildPathComponentTest.java

@Test
public void selectArraySingle() {
    JsonNode nodeBook = NODE.get("store").get("book");

    ArrayNode expected = JsonNodeFactory.instance.arrayNode();
    expected.add(nodeBook.get(0).get("title"));
    expected.add(nodeBook.get(1).get("title"));
    expected.add(nodeBook.get(2).get("title"));
    expected.add(nodeBook.get(3).get("title"));

    JsonNode result = new ChildPathComponent(null, "title").select(nodeBook);

    assertEquals(expected, result);//www .j  av a  2  s  .c om
}