### Question:
ObjectUtils { public static void setBeanProperty(Object object, String prop, String value, Map<String, Object> objects) { prop = makePropertyName(prop); try { boolean found = false; Method[] methods = object.getClass().getMethods(); for (int ix = 0; ix < methods.length && !found; ix++) { if (!methods[ix].getName().equals(prop)) continue; if (methods[ix].getParameterTypes().length != 1) continue; Class type = methods[ix].getParameterTypes()[0]; methods[ix].invoke(object, convertToType(value, type, objects)); found = true; } if (!found) throw new DukeConfigException("Couldn't find method '" + prop + "' in " + "class " + object.getClass()); } catch (IllegalArgumentException e) { throw new DukeConfigException("Couldn't set bean property " + prop + " on object of class " + object.getClass() + ": " + e); } catch (IllegalAccessException e) { throw new DukeException(e); } catch (InvocationTargetException e) { throw new DukeConfigException("Couldn't set bean property " + prop + " on object of class " + object.getClass() + ": " + e); } }  static Object getEnumConstantByName(Class klass, String name); static void setBeanProperty(Object object, String prop, String value,
                                     Map<String, Object> objects); static String makePropertyName(String name); static Object instantiate(String klassname);  }### Answer:
@Test public void testOneWord() { ObjectUtils.setBeanProperty(bean, "property", "value", objects); assertEquals("property not set correctly", "value", bean.getProperty()); }
@Test public void testTwoWords() { ObjectUtils.setBeanProperty(bean, "property-name", "value", objects); assertEquals("property not set correctly", "value", bean.getPropertyName()); }
@Test public void testThreeWords() { ObjectUtils.setBeanProperty(bean, "long-property-name", "value", objects); assertEquals("property not set correctly", "value", bean.getLongPropertyName()); }
@Test public void testIntProperty() { ObjectUtils.setBeanProperty(bean, "int-property", "25", objects); assertEquals("property not set correctly", 25, bean.getIntProperty()); }
@Test public void testBoolProperty() { ObjectUtils.setBeanProperty(bean, "bool-property", "true", objects); assertEquals("property not set correctly", true, bean.getBoolProperty()); }
@Test public void testDoubleProperty() { ObjectUtils.setBeanProperty(bean, "double-property", "0.25", objects); assertEquals("property not set correctly", 0.25, bean.getDoubleProperty()); }
@Test public void testFloatProperty() { ObjectUtils.setBeanProperty(bean, "float-property", "0.25", objects); assertEquals("property not set correctly", 0.25f, bean.getFloatProperty()); }
@Test public void testNamedObject() { objects.put("thetest", this); ObjectUtils.setBeanProperty(bean, "test", "thetest", objects); assertEquals("property not set correctly", this, bean.getTest()); }
@Test public void testEnumConstant() { ObjectUtils.setBeanProperty(bean, "enum", "JACCARD", objects); assertEquals("property not set correctly", QGramComparator.Formula.JACCARD, bean.getEnum()); }
@Test public void testCharProperty() { ObjectUtils.setBeanProperty(bean, "char-property", "g", objects); assertEquals("property not set correctly", 'g', bean.getCharProperty()); }
@Test public void testCharPropertyError() { try { ObjectUtils.setBeanProperty(bean, "char-property", "goo", objects); fail("shouldn't accept three-character string as value of character prop"); } catch (DukeConfigException e) { } }
@Test public void testCollection() { objects.put("foo", "gurgle"); objects.put("bar", "gargle"); ObjectUtils.setBeanProperty(bean, "collection", "foo bar", objects); Collection<String> coll = bean.getCollection(); assertEquals(2, coll.size()); assertTrue(coll.contains("gurgle")); assertTrue(coll.contains("gargle")); }