### Question:
Reflector { public Class<?> getSetterType(String propertyName) { Class<?> clazz = setTypes.get(propertyName); if (clazz == null) { throw new ReflectionException("There is no setter for property named '" + propertyName + "' in '" + type + "'"); } return clazz; } Reflector(Class<?> clazz); Class<?> getType(); Constructor<?> getDefaultConstructor(); boolean hasDefaultConstructor(); Invoker getSetInvoker(String propertyName); Invoker getGetInvoker(String propertyName); Class<?> getSetterType(String propertyName); Class<?> getGetterType(String propertyName); String[] getGetablePropertyNames(); String[] getSetablePropertyNames(); boolean hasSetter(String propertyName); boolean hasGetter(String propertyName); String findPropertyName(String name);  }### Answer:
@Test public void shouldResolveSetterParam() throws Exception { ReflectorFactory reflectorFactory = new DefaultReflectorFactory(); Reflector reflector = reflectorFactory.findForClass(Child.class); assertEquals(String.class, reflector.getSetterType("id")); }
@Test public void shouldResolveParameterizedSetterParam() throws Exception { ReflectorFactory reflectorFactory = new DefaultReflectorFactory(); Reflector reflector = reflectorFactory.findForClass(Child.class); assertEquals(List.class, reflector.getSetterType("list")); }
@Test public void shouldResolveArraySetterParam() throws Exception { ReflectorFactory reflectorFactory = new DefaultReflectorFactory(); Reflector reflector = reflectorFactory.findForClass(Child.class); Class<?> clazz = reflector.getSetterType("array"); assertTrue(clazz.isArray()); assertEquals(String.class, clazz.getComponentType()); }
@Test public void shouldResolveSetterTypeFromPrivateField() throws Exception { ReflectorFactory reflectorFactory = new DefaultReflectorFactory(); Reflector reflector = reflectorFactory.findForClass(Child.class); assertEquals(String.class, reflector.getSetterType("fld")); }
@Test public void shouldResoleveReadonlySetterWithOverload() throws Exception { class BeanClass implements BeanInterface<String> { @Override public void setId(String id) { } } ReflectorFactory reflectorFactory = new DefaultReflectorFactory(); Reflector reflector = reflectorFactory.findForClass(BeanClass.class); assertEquals(String.class, reflector.getSetterType("id")); }
@Test public void testGetSetterType() throws Exception { ReflectorFactory reflectorFactory = new DefaultReflectorFactory(); Reflector reflector = reflectorFactory.findForClass(Section.class); Assert.assertEquals(Long.class, reflector.getSetterType("id")); }