### Question:
RadiologyOrder extends TestOrder { public boolean isDiscontinuationAllowed() { return !this.isDiscontinuedRightNow() && this.isNotInProgress() && this.isNotCompleted(); }  RadiologyStudy getStudy(); void setStudy(RadiologyStudy radiologyStudy); boolean isInProgress(); boolean isNotInProgress(); boolean isCompleted(); boolean isNotCompleted(); boolean isDiscontinuationAllowed();  }### Answer:
@Test public void isDiscontinuationAllowed_shouldReturnFalseIfRadiologyOrderIsDiscontinuedRightNow() throws Exception { Field dateStoppedField = Order.class.getDeclaredField("dateStopped"); dateStoppedField.setAccessible(true); RadiologyOrder radiologyOrder = new RadiologyOrder(); radiologyOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE); radiologyOrder.setDateActivated(Date.from(LocalDateTime.now() .minusMonths(3) .atZone(ZoneId.systemDefault()) .toInstant())); radiologyOrder.setScheduledDate(Date.from(LocalDateTime.now() .minusMonths(2) .atZone(ZoneId.systemDefault()) .toInstant())); dateStoppedField.set(radiologyOrder, Date.from(LocalDateTime.now() .minusMonths(1) .atZone(ZoneId.systemDefault()) .toInstant())); assertFalse(radiologyOrder.isDiscontinuationAllowed()); }
@Test public void isDiscontinuationAllowed_shouldReturnTrueIfRadiologyOrderIsNotDiscontinuedRightNowAndNotInProgressAndNotCompleted() throws Exception { RadiologyOrder radiologyOrder = new RadiologyOrder(); radiologyOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE); radiologyOrder.setScheduledDate(Date.from(LocalDateTime.now() .plusMonths(2) .atZone(ZoneId.systemDefault()) .toInstant())); assertTrue(radiologyOrder.isDiscontinuationAllowed()); }