use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeLongWhenMinimumLessThanIntegerMin.
@Test
public void applyGeneratesIntegerUsingJavaTypeLongWhenMinimumLessThanIntegerMin() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("minimum", Integer.MIN_VALUE - 1L);
when(config.isUsePrimitives()).thenReturn(false);
JType result = rule.apply("fooBar", objectNode, null, jpackage, null);
assertThat(result.fullName(), is(Long.class.getName()));
}
use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeLongPrimitiveWhenMaximumGreaterThanIntegerMax.
@Test
public void applyGeneratesIntegerUsingJavaTypeLongPrimitiveWhenMaximumGreaterThanIntegerMax() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("maximum", Integer.MAX_VALUE + 1L);
when(config.isUsePrimitives()).thenReturn(true);
JType result = rule.apply("fooBar", objectNode, null, jpackage, null);
assertThat(result.fullName(), is("long"));
}
use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeLongWhenMaximumGreaterThanIntegerMax.
@Test
public void applyGeneratesIntegerUsingJavaTypeLongWhenMaximumGreaterThanIntegerMax() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("maximum", Integer.MAX_VALUE + 1L);
when(config.isUsePrimitives()).thenReturn(false);
JType result = rule.apply("fooBar", objectNode, null, jpackage, null);
assertThat(result.fullName(), is(Long.class.getName()));
}
use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeInteger.
@Test
public void applyGeneratesIntegerUsingJavaTypeInteger() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("existingJavaType", "java.lang.Integer");
when(config.isUsePrimitives()).thenReturn(true);
JType result = rule.apply("fooBar", objectNode, null, jpackage, null);
assertThat(result.fullName(), is("java.lang.Integer"));
}
use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesBigIntegerOverridingLong.
@Test
public void applyGeneratesBigIntegerOverridingLong() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
// isUseBigIntegers should override isUseLongIntegers
when(config.isUseBigIntegers()).thenReturn(true);
when(config.isUseLongIntegers()).thenReturn(true);
JType result = rule.apply("fooBar", objectNode, null, jpackage, null);
assertThat(result.fullName(), is(BigInteger.class.getName()));
}
Aggregations