Search in sources :

Example 1 with SimpleMetaDataMap

use of com.day.cq.workflow.metadata.SimpleMetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.

the class RenditionModifyingProcessTest method test_with_null_rendition_arg_is_noop.

@Test
public void test_with_null_rendition_arg_is_noop() throws Exception {
    WorkItem workItem = mock(WorkItem.class);
    MetaDataMap metaData = new SimpleMetaDataMap();
    process.execute(workItem, workflowSession, metaData, workflowHelper);
    verifyZeroInteractions(harness);
}
Also used : SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) MetaDataMap(com.day.cq.workflow.metadata.MetaDataMap) SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) WorkItem(com.day.cq.workflow.exec.WorkItem) Test(org.junit.Test)

Example 2 with SimpleMetaDataMap

use of com.day.cq.workflow.metadata.SimpleMetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.

the class RenditionModifyingProcessTest method test_with_blank_rendition_arg_is_noop.

@Test
public void test_with_blank_rendition_arg_is_noop() throws Exception {
    WorkItem workItem = mock(WorkItem.class);
    MetaDataMap metaData = new SimpleMetaDataMap();
    metaData.put("PROCESS_ARGS", "");
    process.execute(workItem, workflowSession, metaData, workflowHelper);
    verifyZeroInteractions(harness);
}
Also used : SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) MetaDataMap(com.day.cq.workflow.metadata.MetaDataMap) SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) WorkItem(com.day.cq.workflow.exec.WorkItem) Test(org.junit.Test)

Example 3 with SimpleMetaDataMap

use of com.day.cq.workflow.metadata.SimpleMetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.

the class RenditionModifyingProcessTest method test_with_rendition_arg_getting_no_rendition_is_noop.

@Test
public void test_with_rendition_arg_getting_no_rendition_is_noop() throws Exception {
    String path = "/content/dam/some/path.ext";
    WorkItem workItem = mock(WorkItem.class);
    WorkflowData data = mock(WorkflowData.class);
    when(workItem.getWorkflowData()).thenReturn(data);
    when(data.getPayloadType()).thenReturn(WorkflowHelper.TYPE_JCR_PATH);
    when(data.getPayload()).thenReturn(path);
    Resource resource = mock(Resource.class);
    Asset asset = mock(Asset.class);
    when(resource.adaptTo(Asset.class)).thenReturn(asset);
    when(resource.getResourceType()).thenReturn(DamConstants.NT_DAM_ASSET);
    when(resourceResolver.getResource(path)).thenReturn(resource);
    MetaDataMap metaData = new SimpleMetaDataMap();
    metaData.put("PROCESS_ARGS", "renditionName:test");
    process.execute(workItem, workflowSession, metaData, workflowHelper);
    verifyZeroInteractions(harness);
}
Also used : SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) Resource(org.apache.sling.api.resource.Resource) MetaDataMap(com.day.cq.workflow.metadata.MetaDataMap) SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) Asset(com.day.cq.dam.api.Asset) WorkItem(com.day.cq.workflow.exec.WorkItem) WorkflowData(com.day.cq.workflow.exec.WorkflowData) Test(org.junit.Test)

Example 4 with SimpleMetaDataMap

use of com.day.cq.workflow.metadata.SimpleMetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.

the class SendTemplatedEmailProcessTest method test_with_payload_notJcrPath_is_noop.

@Test
public void test_with_payload_notJcrPath_is_noop() throws Exception {
    WorkflowData workflowData = mock(WorkflowData.class);
    when(workItem.getWorkflowData()).thenReturn(workflowData);
    when(workflowData.getPayloadType()).thenReturn("");
    MetaDataMap metaData = new SimpleMetaDataMap();
    process.execute(workItem, workflowSession, metaData);
    verifyZeroInteractions(harness);
}
Also used : SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) MetaDataMap(com.day.cq.workflow.metadata.MetaDataMap) SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) WorkflowData(com.day.cq.workflow.exec.WorkflowData) Test(org.junit.Test)

Example 5 with SimpleMetaDataMap

use of com.day.cq.workflow.metadata.SimpleMetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.

the class SendTemplatedEmailProcessTest method test_with_correct_args_AssetPayload.

@Test
public void test_with_correct_args_AssetPayload() throws Exception {
    String editAssetUrl = "http://localhost:4502/assetdetails.html" + DAM_PAYLOAD_PATH;
    String publishUrl = "http://localhost:4503" + DAM_PAYLOAD_PATH;
    Map<String, String> expectedEmailParams = new HashMap<String, String>();
    expectedEmailParams.put(SendTemplatedEmailConstants.JCR_PATH, DAM_PAYLOAD_PATH);
    expectedEmailParams.put(SendTemplatedEmailConstants.AUTHOR_LINK, editAssetUrl);
    expectedEmailParams.put(SendTemplatedEmailConstants.PUBLISH_LINK, publishUrl);
    WorkflowData workflowData = mock(WorkflowData.class);
    when(workItem.getWorkflowData()).thenReturn(workflowData);
    when(workflowData.getPayloadType()).thenReturn("JCR_PATH");
    MetaDataMap metaData = new SimpleMetaDataMap();
    metaData.put("PROCESS_ARGS", "sendTo:" + GROUP_PATH + ",emailTemplate:" + EMAIL_TEMPLATE);
    // expected build args
    String[] expectedBuildArgs = new String[] { "sendTo:" + GROUP_PATH, "emailTemplate:" + EMAIL_TEMPLATE };
    Object payload = mock(Object.class);
    when(workflowData.getPayload()).thenReturn(payload);
    when(payload.toString()).thenReturn(DAM_PAYLOAD_PATH);
    // mock payload resource
    Resource payloadRes = mock(Resource.class);
    when(resourceResolver.getResource(DAM_PAYLOAD_PATH)).thenReturn(payloadRes);
    when(payloadRes.getPath()).thenReturn(DAM_PAYLOAD_PATH);
    when(payloadRes.getResourceResolver()).thenReturn(resourceResolver);
    when(payloadRes.getResourceType()).thenReturn("dam:Asset");
    // mock authorUI and externalizer
    when(authorUIHelper.generateEditAssetLink(DAM_PAYLOAD_PATH, true, resourceResolver)).thenReturn(editAssetUrl);
    when(externalizer.publishLink(resourceResolver, DAM_PAYLOAD_PATH)).thenReturn(publishUrl);
    when(harness.getEmailAddrs(workItem, payloadRes, expectedBuildArgs)).thenReturn(GROUP_MEMBERS);
    process.execute(workItem, workflowSession, metaData);
    verify(harness, times(1)).getEmailAddrs(workItem, payloadRes, expectedBuildArgs);
    verify(harness, times(1)).getAdditionalParams(workItem, workflowSession, payloadRes);
    verify(emailService, times(1)).sendEmail(EMAIL_TEMPLATE, expectedEmailParams, GROUP_MEMBERS);
}
Also used : HashMap(java.util.HashMap) SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) MetaDataMap(com.day.cq.workflow.metadata.MetaDataMap) SimpleMetaDataMap(com.day.cq.workflow.metadata.SimpleMetaDataMap) Resource(org.apache.sling.api.resource.Resource) WorkflowData(com.day.cq.workflow.exec.WorkflowData) Test(org.junit.Test)

Aggregations

MetaDataMap (com.day.cq.workflow.metadata.MetaDataMap)8 SimpleMetaDataMap (com.day.cq.workflow.metadata.SimpleMetaDataMap)8 Test (org.junit.Test)8 WorkflowData (com.day.cq.workflow.exec.WorkflowData)6 WorkItem (com.day.cq.workflow.exec.WorkItem)4 Resource (org.apache.sling.api.resource.Resource)4 Asset (com.day.cq.dam.api.Asset)2 HashMap (java.util.HashMap)2 Rendition (com.day.cq.dam.api.Rendition)1 RenditionPicker (com.day.cq.dam.api.RenditionPicker)1 Layer (com.day.image.Layer)1 InputStream (java.io.InputStream)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1