@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(MINUTELY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(DAILY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(WEEKLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(HOURLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(SECONDLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(YEARLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(MONTHLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(MINUTELY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(DAILY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(WEEKLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(HOURLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(MONTHLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(QUARTERLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(SECONDLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(QUARTERLY.formatStr()); } };
@Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(YEARLY.formatStr()); } };
public boolean canParseDateString(String dateString) { return formatStr().replaceAll("'", "").length() == dateString.length(); }
public boolean canParseDateString(String dateString) { return formatStr().replaceAll("'", "").length() == dateString.length(); }
@Test(dataProvider = "update-periods") public void test(UpdatePeriod up) throws LensException { // Normal date object parsable String nowStr = up.format(NOW); // Create partition by date object or it's string representation -- both should be same. TimePartition nowPartition = TimePartition.of(up, NOW); TimePartition nowStrPartition = TimePartition.of(up, nowStr); assertEquals(nowPartition, nowStrPartition); // Test next and previous assertTrue(nowPartition.next().after(nowPartition)); assertTrue(nowPartition.previous().before(nowPartition)); // date parse failures should give lens exception assertEquals(getLensExceptionFromPartitionParsing(up, "garbage").getMessage(), TimePartition.getWrongUpdatePeriodMessage(up, "garbage")); getLensExceptionFromPartitionParsing(up, (Date) null); getLensExceptionFromPartitionParsing(up, (String) null); getLensExceptionFromPartitionParsing(up, ""); // parse with other update periods for (UpdatePeriod up2 : UpdatePeriod.values()) { // handles the equality case and the case where monthly-quarterly have same format strings. if (up.formatStr().equals(up2.formatStr())) { continue; } // Parsing a string representation with differnet update period should give lens exception. assertEquals(getLensExceptionFromPartitionParsing(up2, nowStr).getMessage(), TimePartition.getWrongUpdatePeriodMessage(up2, nowStr)); } }