HistoryOverview { public String getDuration() { Duration duration = Duration.between(historyEntry.getStart().toInstant(), historyEntry.getEnd().toInstant()); long seconds = duration.getSeconds(); if (seconds > 0) { return duration.getSeconds() + "s"; } return (duration.getNano() / 1000000) + "ms"; }  @PostConstruct void init(); HistoryEntry getHistory(); String getStart(); String getEnd(); String getDuration(); DonutData getDonutData();  }
@Test public void getDuration() { HistoryEntryImpl entry = new HistoryEntryImpl(); Date now = new Date(); entry.setStart(now); entry.setEnd(now); when(historyUtil.readHistoryEntry(historyResource)).thenReturn(entry); overview.init(); String duration = overview.getDuration(); assertNotNull(duration); }