use of com.sun.codemodel.JType 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, jpackage, null);
assertThat(result.fullName(), is(Long.class.getName()));
}
use of com.sun.codemodel.JType in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeBigInteger.
@Test
public void applyGeneratesIntegerUsingJavaTypeBigInteger() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("javaType", "java.math.BigInteger");
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is("java.math.BigInteger"));
}
use of com.sun.codemodel.JType in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeIntegerPrimitive.
@Test
public void applyGeneratesIntegerUsingJavaTypeIntegerPrimitive() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("javaType", "int");
when(config.isUsePrimitives()).thenReturn(false);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is("int"));
}
use of com.sun.codemodel.JType 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, jpackage, null);
assertThat(result.fullName(), is(Long.class.getName()));
}
use of com.sun.codemodel.JType in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesCustomObject.
@Test
public void applyGeneratesCustomObject() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "object");
JDefinedClass mockObjectType = mock(JDefinedClass.class);
ObjectRule mockObjectRule = mock(ObjectRule.class);
when(mockObjectRule.apply("fooBar", objectNode, jpackage, null)).thenReturn(mockObjectType);
when(ruleFactory.getObjectRule()).thenReturn(mockObjectRule);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result, is((JType) mockObjectType));
}
Aggregations