Package com.fasterxml.jackson.databind.node

Examples of com.fasterxml.jackson.databind.node.TextNode


        assertThat(result.fullName(), equalTo(expectedType.getName()));
    }

    @Test
    public void applyDefaultsToBaseType() {
        TextNode formatNode = TextNode.valueOf("unknown-format");

        JType baseType = new JCodeModel().ref(Long.class);

        JType result = rule.apply("fooBar", formatNode, baseType, null);
View Full Code Here


  public static String addTypeInformation( @Nonnull String type, @Nonnull Version version, @Nonnull byte[] xmlBytes ) throws Exception {
    JsonNode tree = new ObjectMapper().readTree( new String( xmlBytes, Charsets.UTF_8 ) );

    Map<String, JsonNode> newProps = new LinkedHashMap<String, JsonNode>();
    newProps.put( "@type", new TextNode( type ) );
    newProps.put( "@version", new TextNode( version.format() ) );

    Iterator<Map.Entry<String, JsonNode>> nodeIterator = tree.fields();
    while ( nodeIterator.hasNext() ) {
      Map.Entry<String, JsonNode> jsonNode = nodeIterator.next();
      newProps.put( jsonNode.getKey(), jsonNode.getValue() );
View Full Code Here

        ObjectSchema anObviousError = new ObjectSchema();

        schema.getNestedSchemas().add(noErrors);
        schema.getNestedSchemas().add(anObviousError);

        JsonNode nodeToValidate = new TextNode("a string value");

        List<ErrorMessage> result = schema.validate(nodeToValidate);

        assertTrue(result.isEmpty());
    }
View Full Code Here

        schema.getNestedSchemas().add(intSchema);
        schema.getNestedSchemas().add(anotherIntSchema);
        schema.getNestedSchemas().add(nullSchema);
        schema.getNestedSchemas().add(objectSchema);

        JsonNode nodeToValidate = new TextNode("a string value");

        List<ErrorMessage> result = schema.validate(nodeToValidate);

        assertEquals(1, result.size());
        ErrorMessage message = result.get(0);
View Full Code Here

        SimpleTypeSchema nullSchema = new SimpleTypeSchema();
        nullSchema.setType(SimpleType.NULL);
        schema.getNestedSchemas().add(nullSchema);

        JsonNode nodeToValidate = new TextNode("");

        boolean result = schema.isAcceptableType(nodeToValidate);

        assertFalse(result);
    }
View Full Code Here

    }

    @Test
    public void validate_shouldLoadAJsonSchemaFromTheRegistryAndDelegateTheValidateCall() throws Exception {
        URL expectedSchemaLocation = new URL("http://www.example.com/");
        JsonNode expectedDocument = new TextNode("I am a document!!!");
        List<ErrorMessage> expectedResults = Arrays.asList(new ErrorMessage("foo", "bar"));

        JsonSchema mockReferencedSchema = mock(JsonSchema.class);
        when(mockReferencedSchema.validate(expectedDocument)).thenReturn(expectedResults);
        when(registry.getSchema(expectedSchemaLocation)).thenReturn(mockReferencedSchema);
View Full Code Here

    @SuppressWarnings("ConstantConditions")
    @Test
    public void isAcceptableType_shouldDelegateToTheReferencedSchema() throws Exception {
        URL expectedSchemaLocation = new URL("http://www.example.com/");
        JsonNode expectedDocument = new TextNode("I am a document!!!");
        boolean expectedResult = true;

        JsonSchema mockReferencedSchema = mock(JsonSchema.class);
        when(mockReferencedSchema.isAcceptableType(expectedDocument)).thenReturn(expectedResult);
        when(registry.getSchema(expectedSchemaLocation)).thenReturn(mockReferencedSchema);
View Full Code Here

        assertFalse(result);
    }

    @Test
    public void isAcceptableType_shouldReturnFalse_givenAValueNode() throws Exception {
        JsonNode document = new TextNode("blah");
        ArraySchema schema = new ArraySchema();

        boolean result =  schema.isAcceptableType(document);

        assertFalse(result);
View Full Code Here

        JsonToken curr = jp.getCurrentToken();

        if ((curr == JsonToken.VALUE_STRING) || (curr == JsonToken.FIELD_NAME)
            || (curr == JsonToken.VALUE_FALSE) || (curr == JsonToken.VALUE_TRUE)) {
            String name = jp.getText();
            TextNode upperName = ctxt.getNodeFactory().textNode(name.toUpperCase());

            JsonParser treeParser = jp.getCodec().treeAsTokens(upperName);
            treeParser.nextToken();
            return base.deserialize(treeParser, ctxt);
        } else {
View Full Code Here

  public static String addTypeInformation( @Nonnull String type, @Nonnull Version version, @Nonnull byte[] xmlBytes ) throws Exception {
    JsonNode tree = new ObjectMapper().readTree( new String( xmlBytes, Charsets.UTF_8 ) );

    Map<String, JsonNode> newProps = new LinkedHashMap<String, JsonNode>();
    newProps.put( "@type", new TextNode( type ) );
    newProps.put( "@version", new TextNode( version.format() ) );

    Iterator<Map.Entry<String, JsonNode>> nodeIterator = tree.fields();
    while ( nodeIterator.hasNext() ) {
      Map.Entry<String, JsonNode> jsonNode = nodeIterator.next();
      newProps.put( jsonNode.getKey(), jsonNode.getValue() );
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.node.TextNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.