I have a class with a validate method that contains generic type
public class Foo{
private <T> validateThis(T objectToValidate)
{
Set<ConstraintViolation<T>> constraintViolations;
try
{
constraintViolations = validator.validate(objectToValidate);
}
catch(RuntimeException re)
{
throw new HttpStatusUnprocessableEntityException("Unexpected problem occurred);
}
}
however I want to access this method using reflection (i.e for unit testing ) but when I try
Method method =
Foo.class.getDeclaredMethod("validateThis",ParameterizedType.class);
method.setAccessible(true);
I am getting
java.lang.NoSuchMethodException:Foo.validateThis(java.lang.reflect.ParameterizedType)