Skip to content

Commit

Permalink
manually commit the one problematic test
Browse files Browse the repository at this point in the history
  • Loading branch information
signed committed Dec 26, 2018
1 parent 1729ac8 commit 6dcfb6e
Showing 1 changed file with 23 additions and 20 deletions.
Expand Up @@ -25,20 +25,21 @@
import com.github.javaparser.ast.body.AnnotationDeclaration;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.EnumDeclaration;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

import static com.github.javaparser.ast.Modifier.Keyword.PRIVATE;
import static com.github.javaparser.utils.Utils.EOL;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class CompilationUnitBuildersTest {
class CompilationUnitBuildersTest {
private final CompilationUnit cu = new CompilationUnit();

@Test
public void testAddImport() {
void testAddImport() {
cu.addImport(Map.class);
cu.addImport(Map.class);
cu.addImport(List.class);
Expand All @@ -51,7 +52,7 @@ public void testAddImport() {
}

@Test
public void testAddImportArrayTypes() {
void testAddImportArrayTypes() {
cu.addImport(CompilationUnit[][][].class);
cu.addImport(int[][][].class);
cu.addImport(Integer[][][].class);
Expand All @@ -66,22 +67,24 @@ class testInnerClass {
}

@Test
public void testAddImportAnonymousClass() {
void testAddImportAnonymousClass() {
cu.addImport(testInnerClass.class);
assertEquals("import " + testInnerClass.class.getName().replace("$", ".") + ";" + EOL,
cu.getImport(0).toString());
}

@Test(expected = RuntimeException.class)
public void testAddImportInnerClass() {
Object anonymous = new Object() {
@Test
void testAddImportInnerClass() {
assertThrows(RuntimeException.class, () -> {
Object anonymous = new Object(){

};
cu.addImport(anonymous.getClass());
}
};
cu.addImport(anonymous.getClass());
});
}

@Test
public void testAddClass() {
void testAddClass() {
ClassOrInterfaceDeclaration myClassDeclaration = cu.addClass("testClass", PRIVATE);
assertEquals(1, cu.getTypes().size());
assertEquals("testClass", cu.getType(0).getNameAsString());
Expand All @@ -91,7 +94,7 @@ public void testAddClass() {
}

@Test
public void testAddInterface() {
void testAddInterface() {
ClassOrInterfaceDeclaration myInterfaceDeclaration = cu.addInterface("testInterface");
assertEquals(1, cu.getTypes().size());
assertEquals("testInterface", cu.getType(0).getNameAsString());
Expand All @@ -101,7 +104,7 @@ public void testAddInterface() {
}

@Test
public void testAddEnum() {
void testAddEnum() {
EnumDeclaration myEnumDeclaration = cu.addEnum("test");
assertEquals(1, cu.getTypes().size());
assertEquals("test", cu.getType(0).getNameAsString());
Expand All @@ -110,7 +113,7 @@ public void testAddEnum() {
}

@Test
public void testAddAnnotationDeclaration() {
void testAddAnnotationDeclaration() {
AnnotationDeclaration myAnnotationDeclaration = cu.addAnnotationDeclaration("test");
assertEquals(1, cu.getTypes().size());
assertEquals("test", cu.getType(0).getNameAsString());
Expand All @@ -119,22 +122,22 @@ public void testAddAnnotationDeclaration() {
}

@Test
public void testGetClassByName() {
void testGetClassByName() {
assertEquals(cu.addClass("test"), cu.getClassByName("test").get());
}

@Test
public void testGetInterfaceByName() {
void testGetInterfaceByName() {
assertEquals(cu.addInterface("test"), cu.getInterfaceByName("test").get());
}

@Test
public void testGetEnumByName() {
void testGetEnumByName() {
assertEquals(cu.addEnum("test"), cu.getEnumByName("test").get());
}

@Test
public void testGetAnnotationDeclarationByName() {
void testGetAnnotationDeclarationByName() {
assertEquals(cu.addAnnotationDeclaration("test"), cu.getAnnotationDeclarationByName("test").get());
}
}

0 comments on commit 6dcfb6e

Please sign in to comment.