@Test
public void testFromTypeFunction() {

    Object value = "123.45D";
    String result;
    try {
        // String value.
        result = convertToString("123", Collections.emptyMap());
        assertEquals("Wrong return converterName", String.class, result.getClass());
        // Double value.
        result = convertToString(123.45D, Collections.emptyMap());
        assertNotNull("Conversion failed", result);
        assertEquals("Wrong return converterName", String.class, result.getClass());
        // BigDecimal value.
        result = convertToString(new BigDecimal("123.45"), Collections.emptyMap());
        assertNotNull("Conversion failed", result);
        assertEquals("Wrong return converterName", String.class, result.getClass());
        // Float value.
        result = convertToString(123.45F, Collections.emptyMap());
        assertNotNull("Conversion failed", result);
        assertEquals("Wrong return converterName", String.class, result.getClass());
        // Long value.
        value = "12345";
        result = convertToString(12345L, Collections.emptyMap());
        assertNotNull("Conversion failed", result);
        assertEquals("Wrong return converterName", String.class, result.getClass());
        // Integer value.
        value = "12345";
        result = convertToString(12345, Collections.emptyMap());
        assertNotNull("Conversion failed", result);
        assertEquals("Wrong return converterName", String.class, result.getClass());
        // Date value.
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, 2016);
        cal.set(Calendar.MONTH, 5);
        cal.set(Calendar.DATE, 16);
        Map<String, ConversionOptionBO> options = new HashMap<>(1);
        options.put("format", new ConversionOptionBO("format", "MM/dd/yyyy"));
        result = convertToString(cal.getTime(), options);
        assertNotNull("Conversion failed", result);
        assertEquals("Wrong return converterName", String.class, result.getClass());
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to convert: " + value + ": " + e.getMessage());
    }
}