### Question:
DependentSchedule implements Schedule { @Override public SortedSet<ScheduledTime> getScheduledTimes(Scheduler scheduler, ScheduledTime start, ScheduledTime end) { Workflow otherWorkflow = scheduler.getWorkflowConfiguration().findWorkflow(getOtherWorkflowID()); if (otherWorkflow == null) { throw new RuntimeException("Workflow " + getOtherWorkflowID() + " doesn't exist."); } Schedule otherSchedule = otherWorkflow.getSchedule(); return otherSchedule.getScheduledTimes(scheduler, start, end); } DependentSchedule(WorkflowID otherWorkflowID); @Override SortedSet<ScheduledTime> getScheduledTimes(Scheduler scheduler, ScheduledTime start, ScheduledTime end); WorkflowID getOtherWorkflowID();  }### Answer:
@Test public void throwsExceptionContainingWorkflowIDIfWorkflowNotFound() { WorkflowConfiguration emptyConf = new WorkflowConfiguration(); int slidingWindowHours = 24; Scheduler scheduler = new Scheduler(emptyConf, slidingWindowHours); String id = "nonexisting-workflow"; DependentSchedule schedule = new DependentSchedule(new WorkflowID(id)); try { schedule.getScheduledTimes(scheduler, ScheduledTime.now(), ScheduledTime.now()); } catch(Exception e) { if (!e.getMessage().contains(id)) { Assert.assertFalse(true); } } }
@Test public void usesScheduleOfOtherWorkflow() { ScheduledTime workflowStartTime = new ScheduledTime("2015-02-23T00:00Z"); ScheduledTime schedulingStartTime = new ScheduledTime("2015-02-23T10:00Z"); ScheduledTime schedulingEndTime = new ScheduledTime("2015-02-23T12:01Z"); WorkflowConfiguration conf = new WorkflowConfiguration(); int slidingWindowHours = 24; Scheduler scheduler = new Scheduler(conf, slidingWindowHours); String id = "other-workflow"; Schedule otherSchedule = new HourlySchedule(); conf.addWorkflow( new Workflow( new WorkflowID(id), otherSchedule, new SerialSchedulingStrategy(1), new AlwaysTrigger(), new MockExternalService( new MockExternalService.MockExternalStatusSuccess()), slidingWindowHours, workflowStartTime, Workflow.DEFAULT_WAIT_TIMEOUT_SECONDS, new WorkflowInfo(null, Collections.<ContactsInfo>emptyList()))); DependentSchedule schedule = new DependentSchedule(new WorkflowID(id)); SortedSet<ScheduledTime> times = schedule.getScheduledTimes(scheduler, schedulingStartTime, schedulingEndTime); Assert.assertEquals(Sets.newHashSet(new ScheduledTime("2015-02-23T10:00Z"), new ScheduledTime("2015-02-23T11:00Z"), new ScheduledTime("2015-02-23T12:00Z")), times); }