use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver 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.resolution.typesolvers.ReflectionTypeSolver 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.resolution.typesolvers.ReflectionTypeSolver 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());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetAllInterfaces.
@Test
public void testGetAllInterfaces() {
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
// Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess
assertEquals(ImmutableSet.of(Serializable.class.getCanonicalName(), Cloneable.class.getCanonicalName(), List.class.getCanonicalName(), RandomAccess.class.getCanonicalName(), Collection.class.getCanonicalName(), Iterable.class.getCanonicalName()), arraylist.getAllInterfaces().stream().map(i -> i.getQualifiedName()).collect(Collectors.toSet()));
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ReflectionClassDeclarationTest method testGetSuperclassSimpleImplicit.
@Test
public void testGetSuperclassSimpleImplicit() {
class Foo<E> {
E field;
}
TypeSolver typeResolver = new ReflectionTypeSolver();
ResolvedClassDeclaration foo = new ReflectionClassDeclaration(Foo.class, typeResolver);
assertEquals(Object.class.getCanonicalName(), foo.getSuperClass().getQualifiedName());
assertEquals(Collections.emptyList(), foo.getSuperClass().typeParametersValues());
}
Aggregations