Search in sources :

Example 1 with EmailTemplateService

use of org.opencastproject.email.template.api.EmailTemplateService in project opencast by opencast.

the class EmailWorkflowOperationHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
    uriMP = EmailWorkflowOperationHandlerTest.class.getResource("/email_mediapackage.xml").toURI();
    mp = builder.loadFromXml(uriMP.toURL().openStream());
    operationHandler = new EmailWorkflowOperationHandler();
    EmailTemplateService emailTemplateService = EasyMock.createMock(EmailTemplateService.class);
    EasyMock.expect(emailTemplateService.applyTemplate("DCE_workflow_2_body", "This is the media package: ${mediaPackage.identifier}", workflowInstance)).andReturn("This is the media package: 3e7bb56d-2fcc-4efe-9f0e-d6e56422f557");
    EasyMock.expect(emailTemplateService.applyTemplate("template1", null, workflowInstance)).andReturn("This is the media package: 3e7bb56d-2fcc-4efe-9f0e-d6e56422f557");
    EasyMock.expect(emailTemplateService.applyTemplate("templateNotFound", null, workflowInstance)).andReturn("TEMPLATE NOT FOUND!");
    EasyMock.replay(emailTemplateService);
    operationHandler.setEmailTemplateService(emailTemplateService);
    SmtpService smtpService = EasyMock.createMock(SmtpService.class);
    capturedTo = Capture.newInstance();
    capturedCC = Capture.newInstance();
    capturedBCC = Capture.newInstance();
    capturedSubject = Capture.newInstance();
    capturedBody = Capture.newInstance();
    smtpService.send(EasyMock.capture(capturedTo), EasyMock.capture(capturedCC), EasyMock.capture(capturedBCC), EasyMock.capture(capturedSubject), EasyMock.capture(capturedBody));
    EasyMock.expectLastCall().once();
    EasyMock.replay(smtpService);
    operationHandler.setSmtpService(smtpService);
    workflowInstance.setId(1);
    workflowInstance.setState(WorkflowState.RUNNING);
    workflowInstance.setTemplate("DCE-workflow");
    workflowInstance.setMediaPackage(mp);
    WorkflowOperationInstanceImpl failedOperation1 = new WorkflowOperationInstanceImpl("operation1", OperationState.FAILED);
    failedOperation1.setFailWorkflowOnException(true);
    WorkflowOperationInstanceImpl failedOperation2 = new WorkflowOperationInstanceImpl("operation2", OperationState.FAILED);
    failedOperation2.setFailWorkflowOnException(false);
    operation = new WorkflowOperationInstanceImpl("email", OperationState.RUNNING);
    List<WorkflowOperationInstance> operationList = new ArrayList<WorkflowOperationInstance>();
    operationList.add(failedOperation1);
    operationList.add(failedOperation2);
    operationList.add(operation);
    workflowInstance.setOperations(operationList);
}
Also used : SmtpService(org.opencastproject.kernel.mail.SmtpService) EmailTemplateService(org.opencastproject.email.template.api.EmailTemplateService) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) ArrayList(java.util.ArrayList) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 EmailTemplateService (org.opencastproject.email.template.api.EmailTemplateService)1 SmtpService (org.opencastproject.kernel.mail.SmtpService)1 MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)1 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)1 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)1