Package com.fasterxml.jackson.module.jsonSchema

Source Code of com.fasterxml.jackson.module.jsonSchema.TitleSchemaFactoryWrapperTest$Pet

package com.fasterxml.jackson.module.jsonSchema;

import junit.framework.TestCase;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jsonSchema.customProperties.TitleSchemaFactoryWrapper;

public class TitleSchemaFactoryWrapperTest extends TestCase{

  public class Pet {
    public String genus;
  }
 
  public class Person {
    public String name;
    public String hat;
    public Pet pet;
  }
 
  public void testAddingTitle() throws Exception
  {
    TitleSchemaFactoryWrapper visitor = new TitleSchemaFactoryWrapper();
    ObjectMapper mapper = new ObjectMapper();

    mapper.acceptJsonFormatVisitor(Person.class, visitor);
    JsonSchema schema = visitor.finalSchema();

    assertTrue("schema should be an objectSchema.", schema.isObjectSchema());
    String title = schema.asObjectSchema().getTitle();
    assertNotNull(title);
    assertTrue("schema should have a title", title.indexOf("Person") != -1);
    JsonSchema schema2 = schema.asObjectSchema().getProperties().get("pet");
    assertTrue("schema should be an objectSchema.", schema2.isObjectSchema());
    String title2 = schema2.asObjectSchema().getTitle();
    assertNotNull(title2);
    assertTrue("schema should have a title", title2.indexOf("Pet") != -1);
  }
}
TOP

Related Classes of com.fasterxml.jackson.module.jsonSchema.TitleSchemaFactoryWrapperTest$Pet

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.