PodEvents { public static Date convertEventTimestampToDate(String timestamp) throws ParseException { if (Strings.isNullOrEmpty(timestamp)) { throw new IllegalArgumentException("Pod event timestamp can not be blank"); } return new SimpleDateFormat(DATE_FORMAT).parse(timestamp); } private  PodEvents(); static Date convertEventTimestampToDate(String timestamp); static String convertDateToEventTimestamp(Date date);  }
@Test public void eventDateShouldBeBeforeCurrentDate() throws ParseException { String eventTime = "2018-05-15T16:17:54Z"; Date eventDate = PodEvents.convertEventTimestampToDate(eventTime); Assert.assertTrue(eventDate.before(new Date())); }
@Test(expectedExceptions = ParseException.class) public void throwsParseExceptionWhenDateFormatIsInvalid() throws ParseException { String eventTime = "2018-05-15T16:143435Z"; PodEvents.convertEventTimestampToDate(eventTime); }
@Test(expectedExceptions = ParseException.class) public void throwsIllegalArgumentExceptionWhenDateIs12DotSring() throws ParseException { String eventTime = "12."; PodEvents.convertEventTimestampToDate(eventTime); }
@Test(expectedExceptions = IllegalArgumentException.class) public void throwsIllegalArgumentExceptionWhenDateIsNull() throws ParseException { String eventTime = null; PodEvents.convertEventTimestampToDate(eventTime); }
@Test(expectedExceptions = IllegalArgumentException.class) public void throwsIllegalArgumentExceptionWhenDateIsEmptyString() throws ParseException { String eventTime = ""; PodEvents.convertEventTimestampToDate(eventTime); }