Search in sources :

Example 1 with NewJavaFileVisitor

use of org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor in project generator by mybatis.

the class NewJavaFileVisitorTest method testSimpleClass.

@Test
public void testSimpleClass() {
    CompilationUnit cu = getCompilationUnitFromSource(TestResourceGenerator.simpleClassWithAllGeneratedItems());
    NewJavaFileVisitor visitor = new NewJavaFileVisitor();
    cu.accept(visitor);
    assertThat(visitor.getImports().size(), is(0));
    assertThat(visitor.getNewNodes().size(), is(3));
    assertThat(visitor.getSuperclass(), is(nullValue()));
    assertThat(visitor.getSuperInterfaceTypes().size(), is(0));
    assertThat(visitor.isInterface(), is(false));
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) NewJavaFileVisitor(org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor) Test(org.junit.Test)

Example 2 with NewJavaFileVisitor

use of org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor in project generator by mybatis.

the class NewJavaFileVisitorTest method testRegularInterface.

@Test
public void testRegularInterface() throws IOException {
    InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/core/tests/merge/resources/AwfulTableMapper.java.src");
    CompilationUnit cu = getCompilationUnitFromResource(resource);
    NewJavaFileVisitor visitor = new NewJavaFileVisitor();
    cu.accept(visitor);
    assertThat(visitor.getImports().size(), is(11));
    assertThat(visitor.getNewNodes().size(), is(11));
    assertThat(visitor.getSuperclass(), is(nullValue()));
    assertThat(visitor.getSuperInterfaceTypes().size(), is(0));
    assertThat(visitor.isInterface(), is(true));
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) InputStream(java.io.InputStream) NewJavaFileVisitor(org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor) Test(org.junit.Test)

Example 3 with NewJavaFileVisitor

use of org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor in project generator by mybatis.

the class NewJavaFileVisitorTest method testRegularClass.

@Test
public void testRegularClass() throws IOException {
    InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/core/tests/merge/resources/AwfulTable.java.src");
    CompilationUnit cu = getCompilationUnitFromResource(resource);
    NewJavaFileVisitor visitor = new NewJavaFileVisitor();
    cu.accept(visitor);
    assertThat(visitor.getImports().size(), is(1));
    assertThat(visitor.getNewNodes().size(), is(50));
    assertThat(visitor.getSuperclass().isSimpleType(), is(true));
    assertThat(((SimpleType) visitor.getSuperclass()).getName().getFullyQualifiedName(), is("AwfulTableKey"));
    assertThat(visitor.getSuperInterfaceTypes().size(), is(0));
    assertThat(visitor.isInterface(), is(false));
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) SimpleType(org.eclipse.jdt.core.dom.SimpleType) InputStream(java.io.InputStream) NewJavaFileVisitor(org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor) Test(org.junit.Test)

Example 4 with NewJavaFileVisitor

use of org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor in project generator by mybatis.

the class NewJavaFileVisitorTest method testComplexClass.

@Test
public void testComplexClass() throws IOException {
    InputStream resource = getClass().getResourceAsStream("/org/mybatis/generator/eclipse/core/tests/merge/resources/AwfulTableExample.java.src");
    CompilationUnit cu = getCompilationUnitFromResource(resource);
    NewJavaFileVisitor visitor = new NewJavaFileVisitor();
    cu.accept(visitor);
    assertThat(visitor.getImports().size(), is(2));
    assertThat(visitor.getNewNodes().size(), is(17));
    assertThat(visitor.getSuperclass(), is(nullValue()));
    assertThat(visitor.getSuperInterfaceTypes().size(), is(0));
    assertThat(visitor.isInterface(), is(false));
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) InputStream(java.io.InputStream) NewJavaFileVisitor(org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor) Test(org.junit.Test)

Aggregations

CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)4 Test (org.junit.Test)4 NewJavaFileVisitor (org.mybatis.generator.eclipse.core.merge.NewJavaFileVisitor)4 InputStream (java.io.InputStream)3 SimpleType (org.eclipse.jdt.core.dom.SimpleType)1