Tests polishing
This commit is contained in:
@@ -15,6 +15,7 @@ import org.jboss.jandex.IndexView;
|
||||
import org.jboss.jandex.MethodInfo;
|
||||
import org.jboss.jandex.PrimitiveType;
|
||||
import org.jboss.jandex.Type;
|
||||
import org.jboss.jandex.Type.Kind;
|
||||
import org.springframework.ide.vscode.commons.java.IAnnotation;
|
||||
import org.springframework.ide.vscode.commons.java.IField;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaType;
|
||||
@@ -319,7 +320,25 @@ public class Wrappers {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Type from(IJavaType type) {
|
||||
if (type instanceof TypeWrapper) {
|
||||
if (type == IPrimitiveType.BOOLEAN) {
|
||||
return PrimitiveType.BOOLEAN;
|
||||
} else if (type == IPrimitiveType.BYTE) {
|
||||
return PrimitiveType.BYTE;
|
||||
} else if (type == IPrimitiveType.CHAR) {
|
||||
return PrimitiveType.CHAR;
|
||||
} else if (type == IPrimitiveType.DOUBLE) {
|
||||
return PrimitiveType.DOUBLE;
|
||||
} else if (type == IPrimitiveType.FLOAT) {
|
||||
return PrimitiveType.FLOAT;
|
||||
} else if (type == IPrimitiveType.INT) {
|
||||
return PrimitiveType.INT;
|
||||
} else if (type == IPrimitiveType.LONG) {
|
||||
return PrimitiveType.LONG;
|
||||
} else if (type == IPrimitiveType.SHORT) {
|
||||
return PrimitiveType.SHORT;
|
||||
} else if (type == IVoidType.DEFAULT) {
|
||||
return Type.create(null, Kind.VOID);
|
||||
} else if (type instanceof TypeWrapper) {
|
||||
return ((TypeWrapper<Type>)type).getType();
|
||||
}
|
||||
throw new IllegalArgumentException("Not a Jandex wrapped typed!");
|
||||
|
||||
@@ -6,10 +6,13 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.java.IMethod;
|
||||
import org.springframework.ide.vscode.commons.java.IPrimitiveType;
|
||||
import org.springframework.ide.vscode.commons.java.IType;
|
||||
import org.springframework.ide.vscode.commons.java.IVoidType;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
@@ -62,4 +65,27 @@ public class JavaIndexTest {
|
||||
assertEquals(IVoidType.DEFAULT, m.getReturnType());
|
||||
assertEquals(0, m.parameters().count());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void voidConstructor() throws Exception {
|
||||
MavenJavaProject project = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
IType type = project.findType("java.util.ArrayList");
|
||||
assertNotNull(type);
|
||||
IMethod m = type.getMethod("<init>", Stream.empty());
|
||||
assertEquals("<init>", m.getElementName());
|
||||
assertEquals(IVoidType.DEFAULT, m.getReturnType());
|
||||
assertEquals(0, m.parameters().count());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructorMethodWithParams() throws Exception {
|
||||
MavenJavaProject project = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
IType type = project.findType("java.util.ArrayList");
|
||||
assertNotNull(type);
|
||||
IMethod m = type.getMethod("<init>", Stream.of(IPrimitiveType.INT));
|
||||
assertEquals("<init>", m.getElementName());
|
||||
assertEquals(IVoidType.DEFAULT, m.getReturnType());
|
||||
assertEquals(Collections.singletonList(IPrimitiveType.INT), m.parameters().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -682,6 +682,16 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
"bad: BLUE|Expecting a 'demo.Color",
|
||||
"Bogus|Expecting a 'demo.Color"
|
||||
);
|
||||
|
||||
/*
|
||||
* TODO: if enums are not sorted by the 3rd party java indexing lib then
|
||||
* perform the commented out test rather than the above
|
||||
*/
|
||||
// editor.assertProblems(
|
||||
// "bad: BLUE|Expecting a 'demo.Color[RED, GREEN, BLUE]' but got a 'Mapping' node",
|
||||
// "Bogus|Expecting a 'demo.Color[RED, GREEN, BLUE]' but got 'Bogus'"
|
||||
// );
|
||||
|
||||
}
|
||||
|
||||
@Test public void testReconcileSkipIfNoMetadata() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user