### Question:
BeanUtil { @SuppressWarnings({ "rawtypes", "unchecked" }) public static void load(Object model, Map<String, Object> attributes) { for (Entry<String, Object> entry : attributes.entrySet()) { try { Method method = PropertyUtil.getReadMethod(model, entry.getKey()); if (method == null) { continue; } Type propertyType = method.getGenericReturnType() != null ? method.getGenericReturnType() : method.getReturnType(); Object property = PropertyUtil.getProperty(model, entry.getKey()); if (PropertyUtil.isSimpleProperty(entry.getValue().getClass())) { PropertyUtil.setProperty(model, entry.getKey(), entry.getValue()); } else if (PropertyUtil.isCollectionProperty(propertyType, false)) { } else if (PropertyUtil.isMapProperty(propertyType)) { if (property == null) { property = new HashMap(); } loadMap((Map)property, (Map)attributes.get(entry.getKey()), getCollectionElementType(propertyType)); PropertyUtil.setProperty(model, entry.getKey(), property); } else { if (property == null && propertyType instanceof Class) { property = ((Class)propertyType).newInstance(); } load(property, (Map<String, Object>) entry.getValue()); PropertyUtil.setProperty(model, entry.getKey(), property); } } catch (Exception e) { logger.warn("Failed while loading the attributes to the bean", e); } } }  @SuppressWarnings({ "rawtypes", "unchecked" }) static void load(Object model, Map<String, Object> attributes);  }### Answer:
@Test public void shouldLoadBean() { DummyModel3 model3 = new DummyModel3(); BeanUtil.load(model3, this.model3); Map<String, DummyModel2> map = model3.getMap(); assertTrue(map.containsKey("test123")); assertNotNull(map.get("test123").getModel()); assertEquals(map.get("test123").getModel().getIntegerValue(), new Integer(1234)); assertEquals(map.get("test123").getModel().getStringValue(), "string"); }
@Test public void shouldLoadBeanWithMapOfStrings() { Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>(); data.put("stringValue", "string"); data.put("integerValue", "1234"); map.put("map", data); DummyModel2 model2 = new DummyModel2(); BeanUtil.load(model2, map); assertTrue(model2.getMap().containsKey("stringValue")); }