HistoryDataItem { public String getDuration() { if (!STATE.FINISHED.equals(history.getState())) { return ""; } Duration duration = Duration.between(history.getStart().toInstant(), history.getEnd().toInstant()); long seconds = duration.getSeconds(); if (seconds > 0) { return duration.getSeconds() + "s"; } return (duration.getNano() / 1000000) + "ms"; }  @PostConstruct void setup(); String getDate(); String getDuration(); String getStatusIcon(); String getStatusColor(); String getPath(); int getScriptCount();  }
@Test public void getDuration_inprogress() { when(history.getState()).thenReturn(STATE.RUNNING); String duration = item.getDuration(); assertTrue(StringUtils.isBlank(duration)); }
@Test public void getDuration_finished() { when(history.getState()).thenReturn(STATE.FINISHED); when(history.getStart()).thenReturn(new Date()); when(history.getEnd()).thenReturn(new Date()); String duration = item.getDuration(); assertTrue(StringUtils.isNotBlank(duration)); }