use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.
the class FolderRelocatorTest method testRequiredFields.
@Test
public void testRequiredFields() throws LoginException, DeserializeException, RepositoryException {
ResourceResolver rr = getEnhancedMockResolver();
FolderRelocator tool = new FolderRelocatorFactory().createProcessDefinition();
ProcessInstance instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "relocator test");
assertEquals("Folder Relocator: relocator test", instance.getName());
try {
instance.init(rr, Collections.EMPTY_MAP);
fail("That should have thrown an error");
} catch (DeserializeException ex) {
// Expected
}
}
use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.
the class PageRelocatorTest method aclFail.
@Test
public void aclFail() throws LoginException, DeserializeException, RepositoryException, PersistenceException {
ResourceResolver rr = getEnhancedMockResolver(false);
ProcessInstance instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "relocator test");
assertEquals("Page Relocator: relocator test", instance.getName());
initInstance(instance, rr);
instance.run(rr);
assertFalse("ACL issues should have been tracked", instance.getInfo().getReportedErrors().isEmpty());
assertEquals("Aborted", instance.getInfo().getStatus());
}
use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.
the class ControlledProcessManagerServlet method doStartProcess.
private ProcessInstance doStartProcess(SlingHttpServletRequest request) throws RepositoryException, ReflectiveOperationException, DeserializeException {
String def = request.getParameter("definition");
String description = request.getParameter("description");
ProcessDefinition definition = manager.findDefinitionByNameOrPath(def);
ProcessInstance instance = manager.createManagedProcessInstance(definition, description);
instance.init(request.getResourceResolver(), convertRequestMap(request.getRequestParameterMap()));
instance.run(request.getResourceResolver());
return instance;
}
use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.
the class FolderRelocatorTest method barebonesRun.
@Test
public void barebonesRun() throws LoginException, DeserializeException, RepositoryException, PersistenceException {
ResourceResolver rr = getEnhancedMockResolver();
FolderRelocator tool = new FolderRelocatorFactory().createProcessDefinition();
ProcessInstance instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "relocator test");
assertEquals("Folder Relocator: relocator test", instance.getName());
Map<String, Object> values = new HashMap<>();
values.put("sourcePaths", "/content/folderA");
values.put("destinationPath", "/content/folderB");
values.put("mode", FolderRelocator.Mode.MOVE.toString());
instance.init(rr, values);
assertEquals(0.0, instance.updateProgress(), 0.00001);
instance.run(rr);
assertEquals(1.0, instance.updateProgress(), 0.00001);
verify(rr, atLeast(3)).commit();
}
use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.
the class FolderRelocatorTest method testHaltingScenario.
@Test
public void testHaltingScenario() throws DeserializeException, LoginException, RepositoryException, InterruptedException, ExecutionException, PersistenceException {
ResourceResolver rr = getEnhancedMockResolver();
FolderRelocator tool = new FolderRelocatorFactory().createProcessDefinition();
ProcessInstance instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "relocator test");
assertEquals("Folder Relocator: relocator test", instance.getName());
Map<String, Object> values = new HashMap<>();
values.put("sourcePaths", "/content/folderA");
values.put("destinationPath", "/content/folderB");
values.put("mode", FolderRelocator.Mode.MOVE.toString());
instance.init(rr, values);
CompletableFuture<Boolean> f = new CompletableFuture<>();
instance.defineAction("Halt", rr, am -> {
instance.halt();
try {
assertTrue(instance.updateProgress() < 1.0);
assertFalse(instance.getInfo().isIsRunning());
f.complete(true);
} catch (Throwable t) {
f.completeExceptionally(t);
}
});
instance.run(rr);
assertTrue(f.get());
verify(rr, atLeastOnce()).commit();
}
Aggregations