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();
//
Assert.assertNotNull(deploymentDto);
filter.setText(EMAIL_TEXT);
filter.setRecipient(EMAIL_RECIPIENT);
Assert.assertEquals(0, emailLogService.find(filter, null).getTotalElements());
RuntimeService runtimeService = activitiRule.getRuntimeService();
ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_KEY);
//
Assert.assertTrue(instance.isEnded());
long count = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).count();
Assert.assertEquals(0, count);
Assert.assertEquals(1, emailLogService.find(filter, null).getTotalElements());
}
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, InitTestDataProcessor.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());
}
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, InitTestDataProcessor.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(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_CREATED, notifications.get(0).getTopic());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class SendNotificationToApplicantAndImplementerTest method requestRejectedByHelpdeskApplicantImplementerNotSameTest.
@Test
public void requestRejectedByHelpdeskApplicantImplementerNotSameTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
configurationService.setValue(SENT_TO_APPLICANT, "true");
configurationService.setValue(SENT_TO_IMPLEMENTER, "true");
//
IdmIdentityDto testUser3 = createTestUser();
loginAsAdmin(testUser3.getUsername());
IdmIdentityDto test1 = createTestUser();
IdmRoleDto test_role = createRole();
//
IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(test_role, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
taskFilter.setCreatedAfter(now);
List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.find(taskFilter, null, IdmBasePermission.READ).getContent();
assertEquals(0, tasks.size());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
// HELPDESK
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "disapprove");
// test notification to applicant
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(test1.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_DISAPPROVE_IDENTITY_ROLES, notifications.get(0).getTopic());
// test notification to implementer
filter = new IdmNotificationFilter();
filter.setRecipient(testUser3.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
notifications = notificationLogService.find(filter, null).getContent();
assertEquals(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_DISAPPROVE_IDENTITY_ROLES_IMPLEMENTER, notifications.get(0).getTopic());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class SendNotificationToApplicantAndImplementerTest method requestRejectedByHelpdeskApplicantSameTest.
@Test
public void requestRejectedByHelpdeskApplicantSameTest() {
Assert.assertFalse(eventConfiguration.isAsynchronous());
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().setConfigurationValue(SENT_TO_APPLICANT, true);
getHelper().setConfigurationValue(SENT_TO_IMPLEMENTER, false);
//
IdmIdentityDto test1 = createTestUser();
IdmRoleDto test_role = createRole();
loginAsAdmin(test1.getUsername());
IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(test_role, contract, request);
concept = conceptRoleRequestService.save(concept);
request = getHelper().startRequestInternal(request, true, true);
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
taskFilter.setCreatedAfter(now);
List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.find(taskFilter, null, IdmBasePermission.READ).getContent();
assertEquals(0, tasks.size());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
// HELPDESK
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "disapprove");
// test notification
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(test1.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_DISAPPROVE_IDENTITY_ROLES_IMPLEMENTER, notifications.get(0).getTopic());
}
Aggregations