@Test public void testGetDate_null_if_invalid_filename() { // execution ProductData.UTC date = filenameDateExtractor.getDate(new File("invalid_20020304_blah.shp")); // verification assertNull(date); }
@Test public void testGetDate() { // execution ProductData.UTC date = filenameDateExtractor.getDate(new File("20020304_blah.shp")); // verification assertNotNull(date); final int year = 2002; final int month = 3; final int day = 4; assertEquals(year, date.getAsCalendar().get(Calendar.YEAR)); assertEquals( month, date.getAsCalendar().get(Calendar.MONTH) + 1); // +1 ... because the first month of a year has the number 0 assertEquals(day, date.getAsCalendar().get(Calendar.DAY_OF_MONTH)); }