use of com.sun.codemodel.JType 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.JType 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.JType in project jsonschema2pojo by joelittlejohn.
the class FormatRuleJodaTest method applyGeneratesTypeFromFormatValue.
@Test
public void applyGeneratesTypeFromFormatValue() {
TextNode formatNode = TextNode.valueOf(formatValue);
JType result = rule.apply("fooBar", formatNode, new JCodeModel().ref(String.class), null);
assertThat(result.fullName(), equalTo(expectedType.getName()));
}
use of com.sun.codemodel.JType in project jsonschema2pojo by joelittlejohn.
the class FormatRuleTest method applyDefaultsToBaseType.
@Test
public void applyDefaultsToBaseType() {
TextNode formatNode = TextNode.valueOf("unknown-format");
JType baseType = new JCodeModel().ref(Long.class);
JType result = rule.apply("fooBar", formatNode, baseType, null);
assertThat(result, equalTo(baseType));
}
use of com.sun.codemodel.JType in project jsonschema2pojo by joelittlejohn.
the class SchemaRuleTest method existingTypeIsUsedWhenTypeIsAlreadyGenerated.
@Test
public void existingTypeIsUsedWhenTypeIsAlreadyGenerated() throws URISyntaxException {
JType previouslyGeneratedType = mock(JType.class);
URI schemaUri = getClass().getResource("/schema/address.json").toURI();
SchemaStore schemaStore = new SchemaStore();
Schema schema = schemaStore.create(schemaUri, "#/.");
schema.setJavaType(previouslyGeneratedType);
final GenerationConfig mockGenerationConfig = mock(GenerationConfig.class);
when(mockGenerationConfig.getRefFragmentPathDelimiters()).thenReturn("#/.");
when(mockRuleFactory.getSchemaStore()).thenReturn(schemaStore);
when(mockRuleFactory.getGenerationConfig()).thenReturn(mockGenerationConfig);
ObjectNode schemaNode = new ObjectMapper().createObjectNode();
schemaNode.put("$ref", schemaUri.toString());
JType result = rule.apply(NODE_NAME, schemaNode, null, schema);
assertThat(result, is(sameInstance(previouslyGeneratedType)));
}
Aggregations