TriggerInstance { public long getEndTime() { if (Status.isDone(this.getStatus())) { final List<Long> endTimeList = this.depInstances.stream() .map(DependencyInstance::getEndTime).filter(endTime -> endTime != 0) .collect(Collectors.toList()); return endTimeList.isEmpty() ? 0 : Collections.max(endTimeList); } else { return 0; } } TriggerInstance(final String id, final FlowTrigger flowTrigger, final String flowId,
      final int flowVersion, final String submitUser, final List<DependencyInstance>
      depInstances, final int flowExecId, final Project project); @Override String toString(); Project getProject(); String getProjectName(); List<String> getFailureEmails(); String getFlowId(); int getFlowVersion(); int getFlowExecId(); void setFlowExecId(final int flowExecId); final FlowTrigger getFlowTrigger(); void setFlowTrigger(final FlowTrigger flowTrigger); String getSubmitUser(); void addDependencyInstance(final DependencyInstance depInst); List<DependencyInstance> getDepInstances(); String getId(); Status getStatus(); long getStartTime(); long getEndTime();  }
@Test public void testTriggerInstanceEndTime() throws Exception { final List<DependencyInstance> dependencyInstanceList = new ArrayList<>(); Date expectedEndTime = getDate(3, 2, 3); dependencyInstanceList .add(createTestDependencyInstance(Status.SUCCEEDED, CancellationCause.NONE, getDate(2, 2, 2), getDate(3, 2, 3))); dependencyInstanceList .add(createTestDependencyInstance(Status.SUCCEEDED, CancellationCause.NONE, getDate(2, 2, 2), getDate(2, 2, 3))); TriggerInstance ti = null; ti = new TriggerInstance("1", null, "1", 1, "test", dependencyInstanceList, -1, null); assertThat(ti.getEndTime()).isEqualTo(expectedEndTime.getTime()); dependencyInstanceList.clear(); dependencyInstanceList .add(createTestDependencyInstance(Status.RUNNING, CancellationCause.NONE, getDate(2, 2, 2), null)); ti = new TriggerInstance("1", null, "1", 1, "test", dependencyInstanceList, -1, null); assertThat(ti.getEndTime()).isEqualTo(0); dependencyInstanceList.clear(); expectedEndTime = getDate(3, 2, 3); dependencyInstanceList .add(createTestDependencyInstance(Status.SUCCEEDED, CancellationCause.NONE, getDate(2, 2, 3), null)); dependencyInstanceList .add(createTestDependencyInstance(Status.SUCCEEDED, CancellationCause.NONE, getDate(3, 2, 2), null)); dependencyInstanceList .add(createTestDependencyInstance(Status.SUCCEEDED, CancellationCause.NONE, getDate(2, 2, 2), expectedEndTime)); ti = new TriggerInstance("1", null, "1", 1, "test", dependencyInstanceList, -1, null); assertThat(ti.getEndTime()).isEqualTo(expectedEndTime.getTime()); dependencyInstanceList.clear(); ti = new TriggerInstance("1", null, "1", 1, "test", dependencyInstanceList, -1, null); assertThat(ti.getEndTime()).isEqualTo(0); dependencyInstanceList.clear(); }