### Question:
DefaultToSoyDataConverter implements ToSoyDataConverter { protected Object toSoyCompatibleObjects(Object obj) throws Exception { if (obj == null) { return obj; } if (Primitives.isWrapperType(obj.getClass()) || obj instanceof String) { return obj; } if(obj.getClass().isEnum()) { return ((Enum)obj).name(); } if (obj instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) obj; Map<String, Object> newMap = new HashMap<String, Object>(map.size()); for (String key : map.keySet()) { newMap.put(key, toSoyCompatibleObjects(map.get(key))); } return newMap; } if (obj instanceof Iterable<?>) { List<Object> list = Lists.newArrayList(); for (Object subValue : ((Iterable<?>) obj)) { list.add(toSoyCompatibleObjects(subValue)); } return list; } if (obj instanceof Callable) { final Callable<?> callable = (Callable<?>) obj; return toSoyCompatibleObjects(callable.call()); } if (obj.getClass().isArray()) { return obj; } @SuppressWarnings("unchecked") Map<String, Object> pojoMap = (Map<String, Object>) pojoToMap(obj); Map<String, Object> newMap = new HashMap<String, Object>(pojoMap.size()); for (String key : pojoMap.keySet()) { newMap.put(key, toSoyCompatibleObjects(pojoMap.get(key))); } return newMap; } DefaultToSoyDataConverter(); void setIgnorablePropertiesMatcher(
			Matcher<PropertyDescriptor> ignorablePropertiesMatcher); @Override Optional<SoyMapData> toSoyMap(final Object model);  }### Answer:
@Test public void testToSoyCompatibleObjectsWhenObjectIsNull() throws Exception { Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(null); assertNull(testObject); }
@Test public void testToSoyCompatibleObjectsWhenObjectIsString() throws Exception { String testInput = "test"; Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertEquals("test", testObject.toString()); }
@Test public void testToSoyCompatibleObjectsWhenObjectIsEnum() throws Exception { MyEnum testInput = MyEnum.A; Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertEquals("A", testObject.toString()); }
@Test public void testToSoyCompatibleObjectsWhenObjectIsWrapperType() throws Exception { Integer testInput = 42; Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertTrue(testObject instanceof Integer); assertEquals(testInput, (Integer) testObject); }
@Test public void testToSoyCompatibleObjectsWhenObjectIsIterable() throws Exception { List<String> testInput = new ArrayList<String>(); testInput.add("test"); Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertTrue(testObject instanceof Iterable<?>); @SuppressWarnings("unchecked") List<String> actual = (List<String>) testObject; assertEquals(1, actual.size()); assertEquals("test", actual.get(0)); }
@Test public void testToSoyCompatibleObjectsWhenObjectIsArray() throws Exception { String[] testInput = new String[] { "test" }; Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertTrue(testObject.getClass().isArray()); String[] actual = (String[]) testObject; assertEquals(1, actual.length); assertEquals("test", actual[0]); }
@SuppressWarnings("unchecked") @Test public void testToSoyCompatibleObjectsWhenObjectIsPojo() throws Exception { PojoTest testInput = new PojoTest(); Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertTrue(testObject instanceof Map); assertEquals("test", ((Map<String, String>) testObject).get("name")); }
@Test public void testObjectToSoyDataMapWhenObjectIsCallable() throws Exception { Callable<String> testInput = new Callable<String>() { @Override public String call() throws Exception { return "test"; } }; Object testObject = objectToSoyDataConverter .toSoyCompatibleObjects(testInput); assertEquals("test", testObject.toString()); }