Search in sources :

Example 36 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.

the class DefaultNotificationServiceIntegrationTest method stateFilterTest.

@Test
@Ignore
public void stateFilterTest() {
    IdmIdentityDto identity1 = helper.createIdentity();
    IdmIdentityDto identity2 = helper.createIdentity();
    IdmIdentityDto identity3 = helper.createIdentity();
    IdmIdentityDto identity4 = helper.createIdentity();
    List<IdmIdentityDto> identities = Arrays.asList(identity1, identity2, identity3, identity4);
    IdmNotificationTemplateDto template = createTestTemplate("TestTemplate6", "testSubject6");
    IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).build();
    notificationManager.send(message, identities);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setState(NotificationState.ALL);
    Page<IdmNotificationLogDto> result = notificationLogService.find(filter, null);
    assertEquals("Wrong state ALL", 1, result.getTotalElements());
    filter.setState(NotificationState.NOT);
    Page<IdmNotificationLogDto> result2 = notificationLogService.find(filter, null);
    assertEquals("Wrong state NOT", 1, result2.getTotalElements());
    filter.setState(NotificationState.PARTLY);
    result = notificationLogService.find(filter, null);
    assertEquals("Wrong state PARTLY", 0, result.getTotalElements());
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 37 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.

the class NotificationSmtpTest method B_sendEmailViaSmtpByWf.

@Test
public void B_sendEmailViaSmtpByWf() throws InterruptedException, BindPortException, OutOfRangePortException {
    assertTrue(this.isRunning());
    // init observer for this test only
    NotificationObserver observer = new NotificationObserver(2);
    this.addObserver(observer);
    int currentEmails = observer.getEmails().size();
    IdmIdentityDto identity = identityService.getByUsername(TO_WF);
    if (identity == null) {
        identity = helper.createIdentity(TO_WF);
    }
    identity.setEmail("example@example.tld");
    identity = identityService.save(identity);
    processInstanceService.startProcess(WF_NAME, null, InitTestData.TEST_USER_1, null, null);
    // email is send by apache camel asynchronously
    if (observer.getEmails().size() == currentEmails) {
        observer.waitForMails();
    }
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(identity.getUsername());
    filter.setNotificationType(IdmNotificationLog.class);
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    // 
    assertEquals(2, notifications.size());
    assertTrue(this.isRunning());
    assertEquals(currentEmails + 2, observer.getEmails().size());
    for (EmailModel email : observer.getEmails()) {
        assertEquals(FROM, email.getFrom());
        assertEquals(identity.getEmail(), email.getTo());
    }
    // in last test stop smtp server
    this.stopSmtpServer();
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) EmailModel(com.nilhcem.fakesmtp.model.EmailModel) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractNotificationTest(eu.bcvsolutions.idm.test.api.AbstractNotificationTest)

Example 38 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.

the class BasicEmailTest method testSendEmailFromWorkflow.

/**
 * Send email through {@link EmailNotificationSender}
 */
@Test
public void testSendEmailFromWorkflow() {
    // Deploy process - annotation @Deployment can't be used - we need custom behavior to work
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("eu/bcvsolutions/idm/workflow/deploy/testEmailer.bpmn20.xml");
    WorkflowDeploymentDto deploymentDto = processDeploymentService.create(PROCESS_KEY, "testEmailer.bpmn20.xml", is);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    assertNotNull(deploymentDto);
    filter.setText(EMAIL_TEXT);
    filter.setRecipient(EMAIL_RECIPIENT);
    assertEquals(0, emailLogService.find(filter, null).getTotalElements());
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_KEY);
    assertEquals(instance.getActivityId(), "endevent");
    long count = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).count();
    assertEquals(0, count);
    assertEquals(1, emailLogService.find(filter, null).getTotalElements());
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) InputStream(java.io.InputStream) WorkflowDeploymentDto(eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Test(org.junit.Test) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)

Example 39 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.

the class SendNotificationFromTask method sendNotificationGlobalDisabled.

@Test
public void sendNotificationGlobalDisabled() {
    configurationService.setValue(WorkflowConfig.SEND_NOTIFICATION_CONFIGURATION_PROPERTY, Boolean.FALSE.toString());
    // 
    IdmIdentityDto identity = createIdentity(WF_TEST_IDENTITY_03);
    // 
    processInstanceService.startProcess(WF_3_DISABLED_PROCESS_KEY, null, InitTestData.TEST_USER_1, null, null);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(identity.getUsername());
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    // 
    assertEquals(0, notifications.size());
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)

Example 40 with IdmNotificationFilter

use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.

the class SendNotificationFromTask method sendNotificationWithEnabledForm.

@Test
public void sendNotificationWithEnabledForm() {
    configurationService.setValue(WorkflowConfig.SEND_NOTIFICATION_CONFIGURATION_PROPERTY, Boolean.TRUE.toString());
    // 
    IdmIdentityDto identity = createIdentity(WF_TEST_IDENTITY_01);
    // 
    processInstanceService.startProcess(WF_1_ENABLED_PROCESS_KEY, null, InitTestData.TEST_USER_1, null, null);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(identity.getUsername());
    filter.setNotificationType(IdmNotificationLog.class);
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    // 
    assertEquals(2, notifications.size());
    // two notifications - created + assigned, we didnt know order
    if (notifications.get(0).getTopic().equals(CoreModuleDescriptor.TOPIC_WF_TASK_ASSIGNED)) {
        assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_ASSIGNED, notifications.get(0).getTopic());
        assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_CREATED, notifications.get(1).getTopic());
    } else {
        assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_CREATED, notifications.get(0).getTopic());
        assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_ASSIGNED, notifications.get(1).getTopic());
    }
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)

Aggregations

IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)53 Test (org.junit.Test)52 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)50 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)48 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)28 List (java.util.List)28 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)24 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)24 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)24 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)24 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)24 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)24 ArrayList (java.util.ArrayList)24 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)23 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)12 SysProvisioningBreakConfigDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)10 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)7 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)7 InitTestData (eu.bcvsolutions.idm.InitTestData)4 CoreModuleDescriptor (eu.bcvsolutions.idm.core.CoreModuleDescriptor)4