@Test public void createHistoryEntry() throws AecuException { when(resolver.getResource(Mockito.anyString())).thenReturn(resource); HistoryEntry entry = historyUtil.createHistoryEntry(resolver); assertEquals(STATE.RUNNING, entry.getState()); }
public HistoryEntry createHistoryEntry(ResourceResolver resolver) throws AecuException { HistoryEntryImpl history = new HistoryEntryImpl(); Calendar start = new GregorianCalendar(); String basePath = HISTORY_BASE + "/" + start.get(Calendar.YEAR) + "/" + (start.get(Calendar.MONTH) + 1) + "/" + start.get(Calendar.DAY_OF_MONTH); String nodeName = generateHistoryNodeName(); String nodePath = basePath + "/" + nodeName; createPath(basePath, resolver, JcrResourceConstants.NT_SLING_ORDERED_FOLDER); createPath(nodePath, resolver, JcrConstants.NT_UNSTRUCTURED); Resource resource = resolver.getResource(nodePath); ModifiableValueMap values = resource.adaptTo(ModifiableValueMap.class); values.put(ATTR_START, start); values.put(ATTR_STATE, STATE.RUNNING.name()); values.put(ATTR_RESULT, RESULT.UNKNOWN.name()); history.setStart(start.getTime()); history.setRepositoryPath(nodePath); history.setState(STATE.RUNNING); return history; }
HistoryUtil { public HistoryEntry createHistoryEntry(ResourceResolver resolver) throws AecuException { HistoryEntryImpl history = new HistoryEntryImpl(); Calendar start = new GregorianCalendar(); String basePath = HISTORY_BASE + "/" + start.get(Calendar.YEAR) + "/" + (start.get(Calendar.MONTH) + 1) + "/" + start.get(Calendar.DAY_OF_MONTH); String nodeName = generateHistoryNodeName(); String nodePath = basePath + "/" + nodeName; createPath(basePath, resolver, JcrResourceConstants.NT_SLING_ORDERED_FOLDER); createPath(nodePath, resolver, JcrConstants.NT_UNSTRUCTURED); Resource resource = resolver.getResource(nodePath); ModifiableValueMap values = resource.adaptTo(ModifiableValueMap.class); values.put(ATTR_START, start); values.put(ATTR_STATE, STATE.RUNNING.name()); values.put(ATTR_RESULT, RESULT.UNKNOWN.name()); history.setStart(start.getTime()); history.setRepositoryPath(nodePath); history.setState(STATE.RUNNING); return history; } }
HistoryUtil { public HistoryEntry createHistoryEntry(ResourceResolver resolver) throws AecuException { HistoryEntryImpl history = new HistoryEntryImpl(); Calendar start = new GregorianCalendar(); String basePath = HISTORY_BASE + "/" + start.get(Calendar.YEAR) + "/" + (start.get(Calendar.MONTH) + 1) + "/" + start.get(Calendar.DAY_OF_MONTH); String nodeName = generateHistoryNodeName(); String nodePath = basePath + "/" + nodeName; createPath(basePath, resolver, JcrResourceConstants.NT_SLING_ORDERED_FOLDER); createPath(nodePath, resolver, JcrConstants.NT_UNSTRUCTURED); Resource resource = resolver.getResource(nodePath); ModifiableValueMap values = resource.adaptTo(ModifiableValueMap.class); values.put(ATTR_START, start); values.put(ATTR_STATE, STATE.RUNNING.name()); values.put(ATTR_RESULT, RESULT.UNKNOWN.name()); history.setStart(start.getTime()); history.setRepositoryPath(nodePath); history.setState(STATE.RUNNING); return history; }  }
HistoryUtil { public HistoryEntry createHistoryEntry(ResourceResolver resolver) throws AecuException { HistoryEntryImpl history = new HistoryEntryImpl(); Calendar start = new GregorianCalendar(); String basePath = HISTORY_BASE + "/" + start.get(Calendar.YEAR) + "/" + (start.get(Calendar.MONTH) + 1) + "/" + start.get(Calendar.DAY_OF_MONTH); String nodeName = generateHistoryNodeName(); String nodePath = basePath + "/" + nodeName; createPath(basePath, resolver, JcrResourceConstants.NT_SLING_ORDERED_FOLDER); createPath(nodePath, resolver, JcrConstants.NT_UNSTRUCTURED); Resource resource = resolver.getResource(nodePath); ModifiableValueMap values = resource.adaptTo(ModifiableValueMap.class); values.put(ATTR_START, start); values.put(ATTR_STATE, STATE.RUNNING.name()); values.put(ATTR_RESULT, RESULT.UNKNOWN.name()); history.setStart(start.getTime()); history.setRepositoryPath(nodePath); history.setState(STATE.RUNNING); return history; }  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); }
HistoryUtil { public HistoryEntry createHistoryEntry(ResourceResolver resolver) throws AecuException { HistoryEntryImpl history = new HistoryEntryImpl(); Calendar start = new GregorianCalendar(); String basePath = HISTORY_BASE + "/" + start.get(Calendar.YEAR) + "/" + (start.get(Calendar.MONTH) + 1) + "/" + start.get(Calendar.DAY_OF_MONTH); String nodeName = generateHistoryNodeName(); String nodePath = basePath + "/" + nodeName; createPath(basePath, resolver, JcrResourceConstants.NT_SLING_ORDERED_FOLDER); createPath(nodePath, resolver, JcrConstants.NT_UNSTRUCTURED); Resource resource = resolver.getResource(nodePath); ModifiableValueMap values = resource.adaptTo(ModifiableValueMap.class); values.put(ATTR_START, start); values.put(ATTR_STATE, STATE.RUNNING.name()); values.put(ATTR_RESULT, RESULT.UNKNOWN.name()); history.setStart(start.getTime()); history.setRepositoryPath(nodePath); history.setState(STATE.RUNNING); return history; }  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; }