Search in sources :

Example 1 with AnnotationSummary

use of org.mybatis.generator.eclipse.tests.harness.summary.AnnotationSummary in project generator by mybatis.

the class SummarizerTest method testAnnotationSummarizer.

@Test
public void testAnnotationSummarizer() throws IOException {
    InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/tests/harness/tests/resources/OuterAnnotation.src");
    CompilationUnitSummary cuSummary = getCompilationUnitSummaryFromResource(resource);
    assertThat(cuSummary, hasImportCount(4));
    assertThat(cuSummary, hasImport("import java.lang.annotation.ElementType"));
    assertThat(cuSummary, hasImport("import java.lang.annotation.Retention"));
    assertThat(cuSummary, hasImport("import java.lang.annotation.RetentionPolicy"));
    assertThat(cuSummary, hasImport("import java.lang.annotation.Target"));
    assertThat(cuSummary, hasAnnotationCount(2));
    assertThat(cuSummary, hasAnnotation("OuterAnnotation"));
    assertThat(cuSummary, hasAnnotation("SecondOuterAnnotation"));
    assertThat(cuSummary, hasClassCount(0));
    assertThat(cuSummary, hasEnumCount(0));
    assertThat(cuSummary, hasInterfaceCount(0));
    AnnotationSummary annotationSummary = cuSummary.getAnnotationSummary("OuterAnnotation");
    assertThat(annotationSummary, hasAnnotationMember("name"));
    assertThat(annotationSummary, hasAnnotationMemberCount(1));
    assertThat(annotationSummary, hasField("id", ofType("int")));
    assertThat(annotationSummary, hasField("id2", ofType("int")));
    assertThat(annotationSummary, hasField("name", ofType("int")));
    assertThat(annotationSummary, hasFieldCount(3));
    verifyInners(annotationSummary);
}
Also used : InputStream(java.io.InputStream) CompilationUnitSummary(org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary) AnnotationSummary(org.mybatis.generator.eclipse.tests.harness.summary.AnnotationSummary) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 Test (org.junit.Test)1 AnnotationSummary (org.mybatis.generator.eclipse.tests.harness.summary.AnnotationSummary)1 CompilationUnitSummary (org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary)1