use of org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary in project generator by mybatis.
the class SummarizerTest method testClassSummarizer.
@Test
public void testClassSummarizer() throws IOException {
InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/tests/harness/tests/resources/OuterClass.src");
CompilationUnitSummary cuSummary = getCompilationUnitSummaryFromResource(resource);
assertThat(cuSummary, hasImportCount(2));
assertThat(cuSummary, hasImport(IMPORT_JAVA_IO_SERIALIZABLE));
assertThat(cuSummary, hasImport("import java.util.ArrayList"));
assertThat(cuSummary, hasClassCount(2));
assertThat(cuSummary, hasClass("SecondOuterClass"));
assertThat(cuSummary, hasClass("OuterClass"));
assertThat(cuSummary, hasEnumCount(0));
assertThat(cuSummary, hasInterfaceCount(0));
ClassSummary classSummary = cuSummary.getClassSummary("OuterClass");
assertThat(classSummary, hasSuperClass("ArrayList<String>"));
assertThat(classSummary, hasSuperInterface(SERIALIZABLE));
assertThat(classSummary, hasSuperInterfaceCount(1));
assertThat(classSummary, hasField("serialVersionUID", withFieldType("long")));
assertThat(classSummary, hasField("unreliableCount"));
assertThat(classSummary, hasFieldCount(2));
assertThat(classSummary, hasMethod("add(String)"));
assertThat(classSummary, hasMethod("getUnreliableCount()"));
assertThat(classSummary, hasMethodCount(2));
verifyInners(classSummary);
}
use of org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary 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);
}
use of org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary in project generator by mybatis.
the class SummarizerTortureTest method testDifficultMethodsAndFields.
@Test
public void testDifficultMethodsAndFields() throws IOException {
InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/tests/harness/tests/resources/StringifierExercizer.java.src");
CompilationUnitSummary summary = getCompilationUnitSummaryFromResource(resource);
assertThat(summary, hasImportCount(6));
assertThat(summary, hasImport("import static org.junit.Assert.*"));
assertThat(summary, hasImport("import static org.hamcrest.core.IsNot.not"));
assertThat(summary, hasImport("import java.io.Closeable"));
assertThat(summary, hasImport("import java.io.IOException"));
assertThat(summary, hasImport("import java.util.*"));
assertThat(summary, hasImport("import java.math.BigDecimal"));
assertThat(summary, hasClass(CLASS_NAME, withFieldCount(3)));
assertThat(summary, hasClass(CLASS_NAME, withField("primitive1", ofType("int"))));
assertThat(summary, hasClass(CLASS_NAME, withField("decimalArray1", ofType("java.math.BigDecimal[]"))));
assertThat(summary, hasClass(CLASS_NAME, withField("integerArray2", ofType("java.math.BigInteger[][]"))));
assertThat(summary, hasClass(CLASS_NAME, withMethodCount(10)));
assertThat(summary, hasClass(CLASS_NAME, withMethod("emptyMethod()")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("<I extends List<String> & Closeable> intersectionType(I)")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("getPrimitive1()")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("setPrimitive1(int)")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("someMethod(List<Map<Integer,java.lang.String>>,Map<Integer,List<String>>)")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("anotherMethod(String[],String[][])")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("main(String[])")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("method22(List<? extends BigDecimal>)")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("method22(Map<Integer,? super java.math.BigDecimal>)")));
assertThat(summary, hasClass(CLASS_NAME, withMethod("method33(java.lang.String)")));
}
use of org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary in project generator by mybatis.
the class SummarizerTest method testEnumSummarizer.
@Test
public void testEnumSummarizer() throws IOException {
InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/tests/harness/tests/resources/OuterEnum.src");
CompilationUnitSummary cuSummary = getCompilationUnitSummaryFromResource(resource);
assertThat(cuSummary, hasImportCount(1));
assertThat(cuSummary, hasImport(IMPORT_JAVA_IO_SERIALIZABLE));
assertThat(cuSummary, hasClassCount(0));
assertThat(cuSummary, hasEnumCount(2));
assertThat(cuSummary, hasEnum("SecondOuterEnum"));
assertThat(cuSummary, hasEnum("OuterEnum"));
assertThat(cuSummary, hasInterfaceCount(0));
EnumSummary enumSummary = cuSummary.getEnumSummary("OuterEnum");
assertThat(enumSummary, hasEnumConstant("FRED"));
assertThat(enumSummary, hasEnumConstant("WILMA"));
assertThat(enumSummary, hasEnumConstant("BARNEY"));
assertThat(enumSummary, hasEnumConstant("BETTY"));
assertThat(enumSummary, hasEnumConstantCount(4));
assertThat(enumSummary, hasSuperInterface(SERIALIZABLE));
assertThat(enumSummary, hasSuperInterfaceCount(1));
assertThat(enumSummary, hasField("name"));
assertThat(enumSummary, hasFieldCount(1));
assertThat(enumSummary, hasMethod("OuterEnum(String)"));
assertThat(enumSummary, hasMethod("getName()"));
assertThat(enumSummary, hasMethodCount(2));
verifyInners(enumSummary);
}
use of org.mybatis.generator.eclipse.tests.harness.summary.CompilationUnitSummary in project generator by mybatis.
the class SummarizerTest method testInterfaceSummarizer.
@Test
public void testInterfaceSummarizer() throws IOException {
InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/tests/harness/tests/resources/OuterInterface.src");
CompilationUnitSummary cuSummary = getCompilationUnitSummaryFromResource(resource);
assertThat(cuSummary, hasImportCount(1));
assertThat(cuSummary, hasImport(IMPORT_JAVA_IO_SERIALIZABLE));
assertThat(cuSummary, hasClassCount(0));
assertThat(cuSummary, hasEnumCount(0));
assertThat(cuSummary, hasInterfaceCount(2));
assertThat(cuSummary, hasInterface("SecondOuterInterface"));
assertThat(cuSummary, hasInterface("OuterInterface"));
InterfaceSummary interfaceSummary = cuSummary.getInterfaceSummary("OuterInterface");
assertThat(interfaceSummary, hasSuperInterface(SERIALIZABLE));
assertThat(interfaceSummary, hasSuperInterfaceCount(1));
assertThat(interfaceSummary, hasField("MY_NAME"));
assertThat(interfaceSummary, hasFieldCount(1));
assertThat(interfaceSummary, hasMethod("doSomething(int)"));
assertThat(interfaceSummary, hasMethod("doSomethingElse()"));
assertThat(interfaceSummary, hasMethodCount(2));
verifyInners(interfaceSummary);
}
Aggregations