use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesInteger.
@Test
public void applyGeneratesInteger() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is(Integer.class.getName()));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesBigInteger.
@Test
public void applyGeneratesBigInteger() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
when(config.isUseBigIntegers()).thenReturn(true);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is(BigInteger.class.getName()));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class ArrayRuleTest method arrayWithNonUniqueItemsProducesList.
@Test
public void arrayWithNonUniqueItemsProducesList() {
JCodeModel codeModel = new JCodeModel();
JPackage jpackage = codeModel._package(getClass().getPackage().getName());
ObjectMapper mapper = new ObjectMapper();
ObjectNode itemsNode = mapper.createObjectNode();
itemsNode.put("type", "number");
ObjectNode propertyNode = mapper.createObjectNode();
propertyNode.set("uniqueItems", BooleanNode.FALSE);
propertyNode.set("items", itemsNode);
Schema schema = mock(Schema.class);
when(schema.getId()).thenReturn(URI.create("http://example/nonUniqueArray"));
when(config.isUseDoubleNumbers()).thenReturn(true);
JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, schema);
assertThat(propertyType, notNullValue());
assertThat(propertyType.erasure(), is(codeModel.ref(List.class)));
assertThat(propertyType.getTypeParameters().get(0).fullName(), is(Double.class.getName()));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class ArrayRuleTest method arrayWithUniqueItemsProducesSet.
@Test
public void arrayWithUniqueItemsProducesSet() {
JCodeModel codeModel = new JCodeModel();
JPackage jpackage = codeModel._package(getClass().getPackage().getName());
ObjectMapper mapper = new ObjectMapper();
ObjectNode itemsNode = mapper.createObjectNode();
itemsNode.put("type", "integer");
ObjectNode propertyNode = mapper.createObjectNode();
propertyNode.set("uniqueItems", BooleanNode.TRUE);
propertyNode.set("items", itemsNode);
JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, mock(Schema.class));
assertThat(propertyType, notNullValue());
assertThat(propertyType.erasure(), is(codeModel.ref(Set.class)));
assertThat(propertyType.getTypeParameters().get(0).fullName(), is(Integer.class.getName()));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesNumberUsingJavaTypeBigDecimal.
@Test
public void applyGeneratesNumberUsingJavaTypeBigDecimal() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "number");
objectNode.put("javaType", "java.math.BigDecimal");
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is("java.math.BigDecimal"));
}
Aggregations