### Question:
DateType implements Type, Serializable { @Override public Object cast(Object obj) { Date value = null; if (obj != null) { DateFormat fmt = Constants.getDateFormat(); if (obj instanceof Date) { value = (Date) obj; } else if (obj instanceof String) { try { value = fmt.parse((String) obj); } catch (ParseException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; } private  DateType(); @Deprecated static DateFormat getDateFormat(); @Override String getName(); @Override boolean supportsEq(); @Override boolean supportsOrdering(); @Override JsonNode toJson(JsonNodeFactory factory, Object obj); @Override Object fromJson(JsonNode node); @Override Object cast(Object obj); @SuppressWarnings({"rawtypes", "unchecked"}) @Override int compare(Object v1, Object v2); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Deprecated
    static final String DATE_FORMAT_STR; static final Type TYPE; static final String NAME; }### Answer:
@Test public void testCastNull() { assertNull(dateType.cast(null)); }
@Test public void testCastDate() { assertTrue(dateType.cast(new Date()) instanceof Date); }
@Test public void testCastString() { assertTrue(dateType.cast(new SimpleDateFormat(Constants.DATE_FORMAT_STR).format(new Date())) instanceof Date); }
@Test(expected = Error.class) public void testCastBadString() { assertTrue(dateType.cast("badstring") instanceof Date); }
@Test(expected = Error.class) public void testCastOther() { Object object = new Object(); dateType.cast(object); }