Skip to content

Commit

Permalink
Add tests for JsonPropertyDescription value
Browse files Browse the repository at this point in the history
  • Loading branch information
thachhoang committed Dec 7, 2016
1 parent 370d838 commit 2617a45
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package org.jsonschema2pojo.integration.config;

import static org.hamcrest.Matchers.*;
import static org.jsonschema2pojo.integration.util.CodeGenerationHelper.config;
import static org.jsonschema2pojo.integration.util.CodeGenerationHelper.*;
import static org.jsonschema2pojo.integration.util.FileSearchMatcher.*;
import static org.junit.Assert.*;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -30,6 +31,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

Expand Down Expand Up @@ -86,6 +88,14 @@ public void annotationStyleJackson2ProducesJackson2Annotations() throws ClassNot
assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));
}

@Test
public void annotationStyleJackson2ProducesJsonPropertyDescription() throws Exception {
Class<?> generatedType = schemaRule.generateAndCompile("/schema/description/description.json", "com.example", config("annotationStyle", "jackson2")).loadClass("com.example.Description");

Field field = generatedType.getDeclaredField("description");
assertThat(field.getAnnotation(JsonPropertyDescription.class).value(), is("A description for this property"));
}

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJackson1ProducesJackson1Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {
Expand Down

0 comments on commit 2617a45

Please sign in to comment.