use of com.adobe.acs.commons.mcp.impl.ProcessInstanceImpl 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.impl.ProcessInstanceImpl 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.impl.ProcessInstanceImpl in project acs-aem-commons by Adobe-Consulting-Services.
the class BrokenLinksTest method reportBrokenReferences.
@Test
public void reportBrokenReferences() throws Exception {
ResourceResolver rr = getEnhancedMockResolver();
AbstractResourceImpl content = new AbstractResourceImpl("/content", "cq:Page", "cq:Page", new ResourceMetadata());
AbstractResourceImpl pageA = new AbstractResourceImpl("/content/pageA", "cq:Page", "cq:Page", new ResourceMetadata());
content.addChild(pageA);
AbstractResourceImpl pageAcontent = new AbstractResourceImpl("/content/pageA/jcr:content", "cq:PageContent", "cq:PageContent", new ResourceMetadata() {
{
put("ref1", "/content/pageA");
put("ref2", "/content/pageB");
put("ref3", "/content/pageC");
}
});
pageA.addChild(pageAcontent);
AbstractResourceImpl pageB = new AbstractResourceImpl("/content/pageB", "cq:Page", "cq:Page", new ResourceMetadata());
content.addChild(pageB);
AbstractResourceImpl pageBcontent = new AbstractResourceImpl("/content/pageB/jcr:content", "cq:PageContent", "cq:PageContent", new ResourceMetadata() {
{
put("ignoredRef", "/content/pageC");
put("ref2", "/content/pageD");
put("ref3", "/content/pageE");
}
});
pageB.addChild(pageBcontent);
when(rr.getResource("/content")).thenReturn(content);
pageA.setResourceResolver(rr);
pageAcontent.setResourceResolver(rr);
pageB.setResourceResolver(rr);
pageBcontent.setResourceResolver(rr);
when(rr.resolve("/content/pageA")).thenReturn(pageA);
when(rr.resolve("/content/pageB")).thenReturn(pageB);
when(rr.resolve("/content/pageC")).thenReturn(new NonExistingResource(rr, "/content/pageC"));
when(rr.resolve("/content/pageD")).thenReturn(new NonExistingResource(rr, "/content/pageD"));
when(rr.resolve("/content/pageE")).thenReturn(new NonExistingResource(rr, "/content/pageE"));
Map<String, Object> values = new HashMap<>();
values.put("sourcePath", "/content");
values.put("propertyRegex", "^/(etc|content)/.+");
values.put("excludeProperties", "ignoredRef");
ProcessInstanceImpl instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "broken references");
instance.init(rr, values);
instance.run(rr);
Map<String, EnumMap<Report, Object>> reportData = tool.getReportData();
assertEquals(3, reportData.size());
assertEquals("/content/pageC", reportData.get("/content/pageA/jcr:content/ref3").get(Report.reference));
assertEquals("/content/pageD", reportData.get("/content/pageB/jcr:content/ref2").get(Report.reference));
assertEquals("/content/pageE", reportData.get("/content/pageB/jcr:content/ref3").get(Report.reference));
assertFalse("ignoredRef is in the exclude list", reportData.containsKey("/content/pageB/jcr:content/ignoredRef"));
}
use of com.adobe.acs.commons.mcp.impl.ProcessInstanceImpl 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.impl.ProcessInstanceImpl 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