Search in sources :

Example 1 with JDocCommentable

use of com.sun.codemodel.JDocCommentable 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, jclass, null);
    assertThat(result.javadoc(), sameInstance(jclass.javadoc()));
    assertThat(result.javadoc().size(), is(1));
    assertThat((String) result.javadoc().get(0), is("\n(Required)"));
}
Also used : JDocCommentable(com.sun.codemodel.JDocCommentable) JDefinedClass(com.sun.codemodel.JDefinedClass) JCodeModel(com.sun.codemodel.JCodeModel) BooleanNode(com.fasterxml.jackson.databind.node.BooleanNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with JDocCommentable

use of com.sun.codemodel.JDocCommentable 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, jclass, null);
    assertThat(result.javadoc(), sameInstance(jclass.javadoc()));
    assertThat(result.javadoc().size(), is(0));
}
Also used : JDocCommentable(com.sun.codemodel.JDocCommentable) JDefinedClass(com.sun.codemodel.JDefinedClass) JCodeModel(com.sun.codemodel.JCodeModel) BooleanNode(com.fasterxml.jackson.databind.node.BooleanNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 BooleanNode (com.fasterxml.jackson.databind.node.BooleanNode)2 JCodeModel (com.sun.codemodel.JCodeModel)2 JDefinedClass (com.sun.codemodel.JDefinedClass)2 JDocCommentable (com.sun.codemodel.JDocCommentable)2 Test (org.junit.Test)2