use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesArray.
@Test
public void applyGeneratesArray() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "array");
JClass mockArrayType = mock(JClass.class);
ArrayRule mockArrayRule = mock(ArrayRule.class);
when(mockArrayRule.apply("fooBar", objectNode, jpackage, null)).thenReturn(mockArrayType);
when(ruleFactory.getArrayRule()).thenReturn(mockArrayRule);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result, is((JType) mockArrayType));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesAnyAsObject.
@Test
public void applyGeneratesAnyAsObject() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "any");
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is(Object.class.getName()));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesNumberUsingJavaTypeDoublePrimitive.
@Test
public void applyGeneratesNumberUsingJavaTypeDoublePrimitive() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "number");
objectNode.put("javaType", "double");
when(config.isUsePrimitives()).thenReturn(false);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is("double"));
}
use of com.sun.codemodel.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesIntegerUsingJavaTypeLongWhenMinimumGreaterThanIntegerMax.
@Test
public void applyGeneratesIntegerUsingJavaTypeLongWhenMinimumGreaterThanIntegerMax() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "integer");
objectNode.put("minimum", 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.JPackage in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesBigDecimal.
@Test
public void applyGeneratesBigDecimal() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "number");
when(config.isUseBigDecimals()).thenReturn(true);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result.fullName(), is(BigDecimal.class.getName()));
}
Aggregations