### Question:
Date2MinuteConverter implements Converter { public Object convert(@SuppressWarnings("rawtypes") Class clazz, Object value) { if (value == null) return null; if (value instanceof String) { if (!"".equals((String) value)) { try { return new Date2Minute(Date2Minute.formater.parse( (String) value).getTime()); } catch (ParseException e) { throw new CoreException(e); } } else { return null; } } else if (value instanceof Date) { return new Date2Minute(((Date) value).getTime()); } else { return value; } }  Object convert(@SuppressWarnings("rawtypes") Class clazz, Object value);  }### Answer:
@Test public void Null_Date2Minute() { Assert.assertNull(c.convert(null, null)); Assert.assertNull(c.convert(String.class, null)); Assert.assertNull(c.convert(Date.class, null)); Assert.assertNull(c.convert(Date2Minute.class, null)); }
@Test public void String_Date2Minute() { Assert.assertNull(c.convert(Date2Minute.class, "")); Object value = c.convert(Date2Minute.class, "2010-12-01 20:30"); Assert.assertNotNull(value); Assert.assertEquals(Date2Minute.class, value.getClass()); Assert.assertEquals("2010-12-01 20:30", value.toString()); value = c.convert(Date2Minute.class, "2010-12-01 20:30xx"); Assert.assertNotNull(value); Assert.assertEquals(Date2Minute.class, value.getClass()); Assert.assertEquals("2010-12-01 20:30", value.toString()); }
@SuppressWarnings("deprecation") @Test public void Date_Date2Minute() { Date date = new Date(2010 - 1900, 12 - 1, 1, 20, 30, 40); Object value = c.convert(Date2Minute.class, date); Assert.assertNotNull(value); Assert.assertEquals(Date2Minute.class, value.getClass()); Assert.assertEquals("2010-12-01 20:30", value.toString()); }
@Test(expected = CoreException.class) public void error01() { c.convert(Date2Minute.class, "2010-12-01 20"); }
@Test(expected = CoreException.class) public void error02() { c.convert(Date2Minute.class, "2010-12-01"); }