### Question:
EnumType implements ExtendedType<T> { @Override public T materializeObject(ResultSet rs, int index, int type) throws Exception { if (TypesMapping.isNumeric(type)) { int i = rs.getInt(index); return (rs.wasNull() || index < 0) ? null : values[i]; } else { String string = rs.getString(index); return string != null ? Enum.valueOf(enumClass, string) : null; } } EnumType(Class<T> enumClass); @Override String getClassName(); @Override void setJdbcObject(
            PreparedStatement statement,
            T value,
            int pos,
            int type,
            int precision); @Override T materializeObject(ResultSet rs, int index, int type); @Override T materializeObject(CallableStatement rs, int index, int type); @Override String toString(T value);  }### Answer:
@Test public void testMaterializeStringObject() throws Exception { EnumType type = new EnumType(MockEnum.class); MockResultSet rs = new MockResultSet("Test"); rs.addColumn("Enum"); rs.addRow(new Object[] {"b"}); rs.next(); Object o = type.materializeObject(rs, 1, Types.VARCHAR); assertSame(MockEnum.b, o); }
@Test public void testMaterializeNumericObject() throws Exception { EnumType type = new EnumType(MockEnum.class); MockResultSet rs = new MockResultSet("Test"); rs.addColumn("Enum"); rs.addRow(new Object[] {new Integer(2)}); rs.next(); Object o = type.materializeObject(rs, 1, Types.NUMERIC); assertSame(MockEnum.c, o); }
@Test public void testMaterializeStringObjectInnerEnum() throws Exception { EnumType type = new EnumType(InnerEnumHolder.InnerEnum.class); MockResultSet rs = new MockResultSet("Test"); rs.addColumn("Enum"); rs.addRow(new Object[] {"b"}); rs.next(); Object o = type.materializeObject(rs, 1, Types.VARCHAR); assertSame(InnerEnumHolder.InnerEnum.b, o); }
@Test public void testMaterializeNumericObjectInnerEnum() throws Exception { EnumType type = new EnumType(InnerEnumHolder.InnerEnum.class); MockResultSet rs = new MockResultSet("Test"); rs.addColumn("Enum"); rs.addRow(new Object[] {new Integer(2)}); rs.next(); Object o = type.materializeObject(rs, 1, Types.NUMERIC); assertSame(InnerEnumHolder.InnerEnum.c, o); }