/** * Convenience method to determine if the order is activated as of the current date * * @return boolean indicating whether the order was activated before or on the current date * @since 2.0 * @see #isActivated(java.util.Date) */ public boolean isActivated() { return isActivated(new Date()); }
if (!isActivated(checkDate) || dateStopped == null) { return false;
if (!isActivated(checkDate)) { return false;
/** * Convenience method to determine if the order is active as of the specified date * * @param checkDate - the date on which to check order. if null, will use current date * @return boolean indicating whether the order was active on the check date * @since 1.10.1 * @should return true if an order expired on the check date * @should return true if an order was discontinued on the check date * @should return true if an order was activated on the check date * @should return true if an order was activated on the check date but scheduled for the future * @should return false for a voided order * @should return false for a discontinued order * @should return false for an expired order * @should return false for an order activated after the check date * @should return false for a discontinuation order */ public boolean isActive(Date aCheckDate) { if (getVoided() || action == Action.DISCONTINUE) { return false; } Date checkDate = aCheckDate == null ? new Date() : aCheckDate; return isActivated(checkDate) && !isDiscontinued(checkDate) && !isExpired(checkDate); }
/** * @see Order#isActivated(Date) */ @Test public void isActivated_shouldReturnFalseIfDateActivatedIsNull() throws Exception { Order order = new Order(); assertNull(order.getDateActivated()); assertNull(order.getAutoExpireDate()); assertFalse(order.isActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT))); }
/** * @see Order#isActivated(Date) */ @Test public void isActivated_shouldReturnTrueIfAnOrderWasActivatedOnTheCheckDate() throws Exception { Order order = new Order(); Date activationDate = DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT); order.setDateActivated(activationDate); assertNull(order.getDateStopped()); assertNull(order.getAutoExpireDate()); assertTrue(order.isActivated(activationDate)); }
/** * @see Order#isActivated(Date) */ @Test public void isActivated_shouldReturnTrueIfAnOrderWasActivatedBeforeTheCheckDate() throws Exception { Order order = new Order(); Date activationDate = DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT); order.setDateActivated(activationDate); assertNull(order.getDateStopped()); assertNull(order.getAutoExpireDate()); assertTrue(order.isActivated(DateUtils.addMonths(activationDate, 2))); }
/** * @see Order#isActivated(Date) */ @Test public void isActivated_shouldReturnFalseForAnOrderActivatedAfterTheCheckDate() throws Exception { Order order = new Order(); order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)); assertNull(order.getDateStopped()); assertNull(order.getAutoExpireDate()); assertFalse(order.isActivated(DateUtils.addMonths(order.getDateActivated(), -2))); }