use of com.github.javaparser.symbolsolver.model.resolution.TypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetPackageName.
@Test
public void testGetPackageName() {
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
assertEquals("java.util", arraylist.getPackageName());
ResolvedClassDeclaration string = new ReflectionClassDeclaration(String.class, typeResolver);
assertEquals("java.lang", string.getPackageName());
}
use of com.github.javaparser.symbolsolver.model.resolution.TypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetFieldDeclarationTypeVariableInheritance.
@Test
public void testGetFieldDeclarationTypeVariableInheritance() {
class Foo<E> {
E field;
}
class Bar extends Foo<String> {
}
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedReferenceTypeDeclaration foo = new ReflectionClassDeclaration(Foo.class, typeResolver);
ResolvedReferenceTypeDeclaration bar = new ReflectionClassDeclaration(Bar.class, typeResolver);
ResolvedFieldDeclaration fooField = foo.getField("field");
assertEquals(true, fooField.getType().isTypeVariable());
assertEquals("E", fooField.getType().asTypeParameter().getName());
ResolvedFieldDeclaration barField = bar.getField("field");
assertEquals(true, barField.getType().isReferenceType());
assertEquals(String.class.getCanonicalName(), barField.getType().asReferenceType().getQualifiedName());
}
use of com.github.javaparser.symbolsolver.model.resolution.TypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetClassName.
@Test
public void testGetClassName() {
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
assertEquals("ArrayList", arraylist.getClassName());
ResolvedClassDeclaration string = new ReflectionClassDeclaration(String.class, typeResolver);
assertEquals("String", string.getClassName());
}
use of com.github.javaparser.symbolsolver.model.resolution.TypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetAllFields.
// solveMethod
// isAssignableBy
// canBeAssignedTo
// hasField
// solveSymbol
// solveType
// getDeclaredMethods
// getAllMethods
@Test
public void testGetAllFields() {
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
assertEquals(ImmutableSet.of("modCount", "serialVersionUID", "MAX_ARRAY_SIZE", "size", "elementData", "EMPTY_ELEMENTDATA", "DEFAULTCAPACITY_EMPTY_ELEMENTDATA", "DEFAULT_CAPACITY"), arraylist.getAllFields().stream().map(ResolvedDeclaration::getName).collect(Collectors.toSet()));
}
use of com.github.javaparser.symbolsolver.model.resolution.TypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetQualifiedName.
@Test
public void testGetQualifiedName() {
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
assertEquals("java.util.ArrayList", arraylist.getQualifiedName());
ResolvedClassDeclaration string = new ReflectionClassDeclaration(String.class, typeResolver);
assertEquals("java.lang.String", string.getQualifiedName());
}
Aggregations