Example usage for com.fasterxml.jackson.databind.node TextNode TextNode

List of usage examples for com.fasterxml.jackson.databind.node TextNode TextNode

Introduction

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

Prototype

public TextNode(String paramString) 

Source Link

Usage

From source file:com.mapr.synth.samplers.WordSampler.java

@Override
public JsonNode sample() {
    return new TextNode(gen.sample());
}

From source file:com.turn.shapeshifter.transformers.DateTimeTransformerTest.java

@Test(expected = IllegalArgumentException.class)
public void testInvalidValueRubbish() {
    // Completely rubbish
    DateTimeTransformer transformer = new DateTimeTransformer();
    transformer.parse(new TextNode("qux"));
}

From source file:com.github.pjungermann.config.types.json.JsonConverterTest.java

@Test
public void from_hierarchicalJsonObject_convertToConfig() {
    ObjectNode level2 = new ObjectNode(JsonNodeFactory.instance);
    level2.set("an", new TextNode("entry"));

    ObjectNode level1 = new ObjectNode(JsonNodeFactory.instance);
    level1.set("level_2", level2);
    level1.set("another", new TextNode("value"));

    ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
    arrayNode.add(1);//w  ww.j a v a 2s  .  c  o m
    arrayNode.add(2);
    arrayNode.add(3);

    ObjectNode json = new ObjectNode(JsonNodeFactory.instance);
    json.set("level_1", level1);
    json.set("boolean_true", BooleanNode.getTrue());
    json.set("boolean_false", BooleanNode.getFalse());
    json.set("number", new IntNode(123456));
    json.set("string", new TextNode("string value"));
    json.set("list", arrayNode);

    Config config = converter.from(json);

    assertEquals(true, config.get("boolean_true"));
    assertEquals(false, config.get("boolean_false"));
    assertEquals(123456, config.get("number"));
    assertEquals("string value", config.get("string"));
    assertEquals("entry", config.get("level_1.level_2.an"));
    assertEquals("value", config.get("level_1.another"));
    List list = (List) config.get("list");
    assertEquals(1, list.get(0));
    assertEquals(2, list.get(1));
    assertEquals(3, list.get(2));
}

From source file:com.aol.one.patch.DefaultPatcherPatchableListTest.java

@Test
public void testPatchableChildAddValue() throws PatchException {

    PatchOperation operation = new AddOperation("/child/childAddedValue", new TextNode("100"));
    Patcher patcher = PatcherFactory.getDefaultPatcher();

    // TODO: update

}

From source file:com.github.restdriver.matchers.WithSizeTest.java

@Test
public void matcherShouldFailWhenAskedToMatchNonArrayNode() {
    assertThat(matcher.matches(new TextNode("something")), is(false));
}

From source file:com.github.restdriver.matchers.WithValueAtTest.java

@Test
public void matcherShouldFailWhenAskedToMatchNonArrayNode() {
    assertThat(matcher.matches(new TextNode("bar")), is(false));
}

From source file:org.forgerock.openig.migrate.action.ObjectTypeRenameAction.java

@Override
protected ObjectNode doMigrate(final RouteModel route, final ObjectNode configuration) {
    route.getObjects().stream().filter(model -> original.equals(model.getType().getName()))
            .forEach(model -> model.getNode().replace("type", new TextNode(updated)));
    return configuration;
}

From source file:com.squarespace.template.GeneralUtilsTest.java

@Test
public void testIfString() {
    // Truth-y values
    JsonNode node = new IntNode(123);
    assertEquals(GeneralUtils.ifString(node, "000"), "123");
    node = new TextNode("456");
    assertEquals(GeneralUtils.ifString(node, "000"), "456");

    // False-y values
    node = new IntNode(0);
    assertEquals(GeneralUtils.ifString(node, "000"), "000");
    node = NullNode.getInstance();//w w  w  .  j  a va 2s.  co m
    assertEquals(GeneralUtils.ifString(node, "000"), "000");
}

From source file:com.github.restdriver.matchers.ContainingValueTest.java

@Test
public void matcherShouldFailWhenAskedToMatchNonArrayNode() {
    assertThat(matcher.matches(new TextNode("foo")), is(false));
}

From source file:com.turn.shapeshifter.transformers.DateTimeTransformerTest.java

@Test(expected = IllegalArgumentException.class)
public void testInvalidValueMissingTimezone() {
    // Missing timezone
    DateTimeTransformer transformer = new DateTimeTransformer();
    transformer.parse(new TextNode("1981-10-17T21:00:00.000"));
}