Search in sources :

Example 6 with ProcessInstance

use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.

the class PageRelocatorTest method barebonesRun.

@Test
public void barebonesRun() throws LoginException, DeserializeException, RepositoryException, PersistenceException {
    ResourceResolver rr = getEnhancedMockResolver(true);
    ProcessInstance instance = new ProcessInstanceImpl(getControlledProcessManager(), tool, "relocator test");
    assertEquals("Page Relocator: relocator test", instance.getName());
    initInstance(instance, rr);
    assertEquals(0.0, instance.updateProgress(), 0.00001);
    instance.run(rr);
    assertEquals(1.0, instance.updateProgress(), 0.00001);
    verify(rr, atLeast(3)).commit();
}
Also used : ProcessInstanceImpl(com.adobe.acs.commons.mcp.impl.ProcessInstanceImpl) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) Test(org.junit.Test) ActionManagerTest(com.adobe.acs.commons.fam.impl.ActionManagerTest)

Example 7 with ProcessInstance

use of com.adobe.acs.commons.mcp.ProcessInstance 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();
}
Also used : ActionManager(com.adobe.acs.commons.fam.ActionManager) ProcessInstanceImpl(com.adobe.acs.commons.mcp.impl.ProcessInstanceImpl) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) Test(org.junit.Test) ActionManagerTest(com.adobe.acs.commons.fam.impl.ActionManagerTest)

Example 8 with ProcessInstance

use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.

the class ControlledProcessManagerImpl method createManagedProcessInstance.

@Override
public ProcessInstance createManagedProcessInstance(ProcessDefinition definition, String description) {
    ProcessInstance instance = new ProcessInstanceImpl(this, definition, description);
    activeProcesses.put(instance.getId(), instance);
    return instance;
}
Also used : ArchivedProcessInstance(com.adobe.acs.commons.mcp.model.impl.ArchivedProcessInstance) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance)

Example 9 with ProcessInstance

use of com.adobe.acs.commons.mcp.ProcessInstance in project acs-aem-commons by Adobe-Consulting-Services.

the class ControlledProcessManagerImpl method getInactiveProcesses.

@Override
public Collection<ProcessInstance> getInactiveProcesses() {
    ArrayList<ProcessInstance> processes = new ArrayList();
    try (ResourceResolver rr = getServiceResourceResolver()) {
        Resource tree = rr.getResource(ProcessInstanceImpl.BASE_PATH);
        TreeFilteringResourceVisitor visitor = new TreeFilteringResourceVisitor();
        visitor.setLeafVisitor((r, l) -> {
            if (!activeProcesses.containsKey(r.getName())) {
                processes.add(r.adaptTo(ArchivedProcessInstance.class));
            }
        });
        visitor.accept(tree);
    } catch (LoginException ex) {
        LOG.error("Error getting inactive process list", ex);
    }
    return processes;
}
Also used : TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Resource(org.apache.sling.api.resource.Resource) LoginException(org.apache.sling.api.resource.LoginException) ArchivedProcessInstance(com.adobe.acs.commons.mcp.model.impl.ArchivedProcessInstance) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) ArchivedProcessInstance(com.adobe.acs.commons.mcp.model.impl.ArchivedProcessInstance)

Aggregations

ProcessInstance (com.adobe.acs.commons.mcp.ProcessInstance)9 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)7 ActionManagerTest (com.adobe.acs.commons.fam.impl.ActionManagerTest)6 ProcessInstanceImpl (com.adobe.acs.commons.mcp.impl.ProcessInstanceImpl)6 Test (org.junit.Test)6 ArchivedProcessInstance (com.adobe.acs.commons.mcp.model.impl.ArchivedProcessInstance)2 HashMap (java.util.HashMap)2 ActionManager (com.adobe.acs.commons.fam.ActionManager)1 ProcessDefinition (com.adobe.acs.commons.mcp.ProcessDefinition)1 DeserializeException (com.adobe.acs.commons.mcp.util.DeserializeException)1 TreeFilteringResourceVisitor (com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)1 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 LoginException (org.apache.sling.api.resource.LoginException)1 Resource (org.apache.sling.api.resource.Resource)1