HistoryUtil { public void finishHistoryEntry(HistoryEntry history, ResourceResolver resolver) { Resource resource = resolver.getResource(history.getRepositoryPath()); ModifiableValueMap values = resource.adaptTo(ModifiableValueMap.class); Calendar end = new GregorianCalendar(); values.put(ATTR_END, end); values.put(ATTR_STATE, STATE.FINISHED.name()); values.put(ATTR_RESULT, history.getResult().name()); ((HistoryEntryImpl) history).setEnd(end.getTime()); ((HistoryEntryImpl) history).setState(STATE.FINISHED); }  HistoryEntry createHistoryEntry(ResourceResolver resolver); void storeExecutionInHistory(HistoryEntry history, ExecutionResult result, ResourceResolver resolver); void finishHistoryEntry(HistoryEntry history, ResourceResolver resolver); List<HistoryEntry> getHistory(int startIndex, int count, ResourceResolver resolver); Resource getHistoryEntryResource(Resource child); HistoryEntry readHistoryEntry(Resource resource); ExecutionResult readHistorySingleResult(Resource resource); void purgeHistory(ResourceResolver resolver, int daysToKeep); void selfCheck(ResourceResolver resolver); static final String HISTORY_BASE; static final String NODE_FALLBACK; static final String ATTR_PATH; }
@Test public void finishHistoryEntry() { when(resolver.getResource(Mockito.anyString())).thenReturn(resource); HistoryEntry history = mock(HistoryEntryImpl.class); when(history.getRepositoryPath()).thenReturn("path"); when(history.getResult()).thenReturn(RESULT.SUCCESS); historyUtil.finishHistoryEntry(history, resolver); verify(valueMap, times(1)).put("state", STATE.FINISHED.name()); }