Package com.fasterxml.jackson.module.jsonSchema.failing

Source Code of com.fasterxml.jackson.module.jsonSchema.failing.TestUnwrapping$Name

package com.fasterxml.jackson.module.jsonSchema.failing;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;
import com.fasterxml.jackson.module.jsonSchema.SchemaTestBase;

public class TestUnwrapping extends SchemaTestBase
{
    static class UnwrappingRoot
    {
        public int age;

        @JsonUnwrapped
        public Name name;
    }

    static class Name {
        @JsonUnwrapped(prefix="name.")
        public String first, last;
    }

    /*
    /**********************************************************
    /* Unit tests, success
    /**********************************************************
     */
   
    private final ObjectMapper MAPPER = objectMapper();

    public void testUnwrapping()  throws Exception
    {
        JsonSchemaGenerator generator = new JsonSchemaGenerator(MAPPER);
        JsonSchema schema = generator.generateSchema(UnwrappingRoot.class);

        String json = MAPPER.writeValueAsString(schema).replace('"', '\'');
       
//System.err.println("JSON -> "+MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(schema));
        String EXP = "{'type':'object','properties':{"
        +"'name.last':{'type':'string'},'name.first':{'type':'string'},"
        +"'age':{'type':'number','type':'integer'}}}";

System.err.println("EXP: "+EXP);
System.err.println("ACT: "+json);
       
        assertEquals(EXP, json);
    }
}
TOP

Related Classes of com.fasterxml.jackson.module.jsonSchema.failing.TestUnwrapping$Name

TOP
Copyright © 2018 www.massapi.com. 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.