MapPropertyDescriptor extends GetterSetterPropertyDescriptor { @Override public Method getWriteMethod() { if (MappingUtils.isBlankOrNull(setMethodName)) { throw new MappingException("Custom Map set method not specified for field mapping to class: " + clazz + ". Perhaps the map-set-method wasn't specified in the dozer mapping file?"); } if (writeMethod == null || writeMethod.get() == null) { Method method = findMapMethod(clazz, setMethodName, 2); writeMethod = new SoftReference<>(method); } return writeMethod.get(); } MapPropertyDescriptor(Class<?> clazz, String fieldName, boolean isIndexed, int index, String setMethod, String getMethod,
                                 String key, HintContainer srcDeepIndexHintContainer, HintContainer destDeepIndexHintContainer,
                                 BeanContainer beanContainer, DestBeanCreator destBeanCreator); @Override Method getWriteMethod(); @Override void setPropertyValue(Object bean, Object value, FieldMap fieldMap);  }
@Test public void testGetWriteMethod() { Method method = descriptor.getWriteMethod(); assertEquals(2, method.getParameterTypes().length); assertTrue(Arrays.equals(new Class[] {String.class, Object.class}, method.getParameterTypes())); }
@Test(expected = MappingException.class) public void testGetWriteMethod_NotFound() { descriptor = new MapPropertyDescriptor(MapStructure.class, "", false, 0, "missing_set", "get", "key", null, null, beanContainer, destBeanCreator); descriptor.getWriteMethod(); fail(); }