### Question:
ClassUtils { static Class<?> getSetterType(Method setter) { Class<?>[] parameterTypes = setter.getParameterTypes(); if (parameterTypes.length != 1) { throw new BeanUtilsException( String.format("Method %s has %d parameters and cannot be a setter", setter.getName(), parameterTypes.length)); } return parameterTypes[0]; } private  ClassUtils();   }### Answer:
@Test(expectedExceptions = {BeanUtilsException.class}) public void getSetterTypeWithIncorrectSignature2() throws Exception { Method otherMethod = TestBean.class.getDeclaredMethod("otherMethod", String.class, int.class); Class<?> type = ClassUtils.getSetterType(otherMethod); }
@Test public void getSetterType() { Method setter = ClassUtils.getSetter(TestBean.class, "strField", String.class); Class<?> type = ClassUtils.getSetterType(setter); Assert.assertEquals(type, String.class); }
@Test(expectedExceptions = {BeanUtilsException.class}) public void getSetterTypeWithIncorrectSignature() throws Exception { Method getter = TestBean.class.getDeclaredMethod("getStrField"); Class<?> type = ClassUtils.getSetterType(getter); }