@Test public void testGetCheckedConstructorReturnConstructor() { Constructor<?> constructor = new ExceptionFactory().getCheckedConstructor(Throwable.class, String.class); assertThat(constructor, not(nullValue())); Class<?> declaringClass = constructor.getDeclaringClass(); assertThat(declaringClass.equals(Throwable.class), equalTo(true)); assertThat(constructor.getParameterTypes().length, equalTo(1)); Class<?> parameterType = constructor.getParameterTypes()[0]; assertThat(parameterType.equals(String.class), equalTo(true)); }
@Test public void testGetExceptionConstructorFindStringConstructor() { Constructor<?> constructor = new ExceptionFactory().getExceptionConstructor(Exception.class); assertThat(constructor, not(nullValue())); assertThat(constructor.getParameterTypes().length, equalTo(1)); Class<?> parameterType = constructor.getParameterTypes()[0]; assertThat(parameterType.equals(String.class), equalTo(true)); }