use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class CommentRuleTest method applyAddsCommentToJavadoc.
@Test
public void applyAddsCommentToJavadoc() throws JClassAlreadyExistsException {
JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME);
ObjectMapper mapper = new ObjectMapper();
TextNode commentNode = mapper.createObjectNode().textNode("some comment");
JDocComment result = rule.apply("fooBar", commentNode, null, jclass, null);
assertThat(result, sameInstance(jclass.javadoc()));
assertThat(result.size(), is(1));
assertThat((String) result.get(0), is("some comment"));
}
use of com.sun.codemodel.JCodeModel 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, null, new JCodeModel().ref(String.class), null);
assertThat(result.fullName(), equalTo(expectedType.getName()));
}
use of com.sun.codemodel.JCodeModel 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, null, baseType, null);
assertThat(result, equalTo(baseType));
}
use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class RequiredRuleTest method applyAddsTextWhenRequired.
@Test
public void applyAddsTextWhenRequired() throws JClassAlreadyExistsException {
JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME);
ObjectMapper mapper = new ObjectMapper();
BooleanNode descriptionNode = mapper.createObjectNode().booleanNode(true);
JDocCommentable result = rule.apply("fooBar", descriptionNode, null, jclass, null);
assertThat(result.javadoc(), sameInstance(jclass.javadoc()));
assertThat(result.javadoc().size(), is(1));
assertThat((String) result.javadoc().get(0), is("\n(Required)"));
}
use of com.sun.codemodel.JCodeModel in project jsonschema2pojo by joelittlejohn.
the class RequiredRuleTest method applySkipsTextWhenNotRequired.
@Test
public void applySkipsTextWhenNotRequired() throws JClassAlreadyExistsException {
JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME);
ObjectMapper mapper = new ObjectMapper();
BooleanNode descriptionNode = mapper.createObjectNode().booleanNode(false);
JDocCommentable result = rule.apply("fooBar", descriptionNode, null, jclass, null);
assertThat(result.javadoc(), sameInstance(jclass.javadoc()));
assertThat(result.javadoc().size(), is(0));
}
Aggregations