private String fromCalendar(boolean withBrackets) { StringBuilder result = new StringBuilder(); if (withBrackets) { result.append(isActive() ? '<' : '['); } result.append(DATE_FORMAT.format(cal.getTime())); if (hasTime) { result.append(" "); result.append(TIME_FORMAT.format(cal.getTime())); if (endCal != null) { result.append("-"); result.append(TIME_FORMAT.format(endCal.getTime())); } } if (hasRepeater()) { result.append(" "); result.append(repeater); } if (hasDelay()) { result.append(" "); result.append(delay); } if (withBrackets) { result.append(isActive() ? '>' : ']'); } return result.toString(); }
@Test public void testDelayOnlyWithTime() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 13:15 -2d>"); Assert.assertFalse(time.hasRepeater()); Assert.assertTrue(time.hasDelay()); Assert.assertEquals(OrgDelay.Type.ALL, time.getDelay().getType()); Assert.assertEquals(2, time.getDelay().getValue()); Assert.assertEquals(OrgDelay.Unit.DAY, time.getDelay().getUnit()); }
@Test public void testDelayOnlyWithWeekday() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 Wed -2d>"); Assert.assertFalse(time.hasRepeater()); Assert.assertTrue(time.hasDelay()); Assert.assertEquals(OrgDelay.Type.ALL, time.getDelay().getType()); Assert.assertEquals(2, time.getDelay().getValue()); Assert.assertEquals(OrgDelay.Unit.DAY, time.getDelay().getUnit()); }
@Test public void testDelayFirstOccurrence() { OrgDateTime time = OrgDateTime.parse("<2009-10-17 13:15 +1m --2d>"); Assert.assertTrue(time.hasRepeater()); Assert.assertTrue(time.hasDelay()); Assert.assertEquals(OrgDelay.Type.FIRST_ONLY, time.getDelay().getType()); Assert.assertEquals(2, time.getDelay().getValue()); Assert.assertEquals(OrgDelay.Unit.DAY, time.getDelay().getUnit()); }