use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.
the class ActionManagerTest method nullStatsCounterTest.
@Test
public void nullStatsCounterTest() throws LoginException, Exception {
// Counters don't do tabulate in-thread actions, only deferred actions
ResourceResolver rr = getMockResolver();
ActionManager manager = getActionManager();
assertEquals(0, manager.getAddedCount());
manager.withResolver(resolver -> {
});
assertEquals(0, manager.getAddedCount());
assertEquals(0, manager.getCompletedCount());
manager.withResolver(resolver -> {
});
assertEquals(0, manager.getAddedCount());
assertEquals(0, manager.getCompletedCount());
assertEquals(0, manager.getErrorCount());
assertEquals(0, manager.getRemainingCount());
assertTrue(manager.isComplete());
}
use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.
the class FolderRelocatorTest method getControlledProcessManager.
private ControlledProcessManager getControlledProcessManager() throws LoginException {
ActionManager am = getActionManager();
ActionManagerFactory amf = mock(ActionManagerFactoryImpl.class);
when(amf.createTaskManager(any(), any(), anyInt())).thenReturn(am);
ControlledProcessManager cpm = mock(ControlledProcessManager.class);
when(cpm.getActionManagerFactory()).thenReturn(amf);
return cpm;
}
use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.
the class PageRelocatorTest method validateMoveOperation.
@Test
public void validateMoveOperation() throws RepositoryException, LoginException, DeserializeException, PersistenceException {
ResourceResolver rr = getEnhancedMockResolver(true);
ProcessInstance instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "relocator test");
initInstance(instance, rr);
ActionManager manager = getActionManager();
tool.movePages(manager);
assertTrue("Should be no reported errors", manager.getErrorCount() == 0);
assertFalse("Should have captured activate requests", tool.replicatorQueue.activateOperations.isEmpty());
assertFalse("Should have captured deactivate requests", tool.replicatorQueue.deactivateOperations.isEmpty());
// Our mock doesn't pretend to create target pages at the moment...
// Resource pageB = rr.getResource("/content/pageB");
// verify(rr, times(1)).create(eq(pageB), eq("pageA"), any());
verify(rr, atLeastOnce()).commit();
}
use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.
the class FolderRelocator method buildTargetFolders.
private void buildTargetFolders(ActionManager step2) {
TreeFilteringResourceVisitor folderVisitor = new TreeFilteringResourceVisitor();
folderVisitor.setBreadthFirstMode();
folderVisitor.setResourceVisitor((res, level) -> {
String path = res.getPath();
step2.deferredWithResolver(Actions.retry(5, 100, rr -> buildDestinationFolder(rr, path)));
});
sourceToDestination.keySet().forEach(sourcePath -> beginStep(step2, sourcePath, folderVisitor));
}
use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.
the class StatusServlet method addActionManagerTrackedCounts.
private void addActionManagerTrackedCounts(String name, JSONObject json) throws JSONException {
final ActionManager actionManager = actionManagerFactory.getActionManager(name);
int failureCount = actionManager.getErrorCount();
int completeCount = actionManager.getSuccessCount();
int totalCount = actionManager.getAddedCount();
int remainingCount = actionManager.getRemainingCount();
json.put("totalCount", totalCount);
json.put("completeCount", completeCount);
json.put("remainingCount", remainingCount);
json.put("failCount", failureCount);
json.put("percentComplete", Math.round(((totalCount - remainingCount) / (totalCount * 1F)) * DECIMAL_TO_PERCENT));
}
Aggregations