### Question:
EnumConverter extends Converter<T> { @Override @SuppressWarnings("unchecked") protected T convert(Object object, Class<T> type) { if (ExtendedEnumeration.class.isAssignableFrom(type)) { ExtendedEnumeration[] values; try { values = (ExtendedEnumeration[]) type.getMethod("values").invoke(null); } catch (Exception e) { throw new CayenneRuntimeException(e); } for (ExtendedEnumeration en : values) { if (Util.nullSafeEquals(en.getDatabaseValue(), object)) { return (T) en; } } return null; } if (object == null) { return null; } return (T) Enum.valueOf(type, object.toString()); }    }### Answer:
@Test public void testConvert() { EnumConverter converter = new EnumConverter(); assertSame(MockEnum2.x, converter.convert("x", MockEnum2.class)); assertSame(MockEnum2.z, converter.convert("z", MockEnum2.class)); }
@Test public void testConvertExtendedEnumeration() { EnumConverter converter = new EnumConverter(); assertSame(MockEnum3.B, converter.convert(2, MockEnum3.class)); assertSame(MockEnum3.C, converter.convert(3, MockEnum3.class)); }
@Test public void testConvertExtendedEnumerationWithNull() { EnumConverter converter = new EnumConverter(); assertSame(MockEnum4.B, converter.convert(null, MockEnum4.class)); assertSame(MockEnum4.C, converter.convert("3", MockEnum4.class)); }