use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto 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.IdmNotificationLogDto in project CzechIdMng by bcvsolutions.
the class DeleteNotificationTaskExecutorIntegrationTest method createDto.
private IdmNotificationLogDto createDto(String subject, ZonedDateTime created, NotificationState state) {
IdmNotificationLogDto notification = new IdmNotificationLogDto();
notification.setCreated(created);
notification.setMessage(new IdmMessageDto.Builder(NotificationLevel.SUCCESS).setSubject(subject).setMessage("mock").build());
notification.setSent(state == NotificationState.ALL ? created : null);
notification = service.save(notification);
//
if (state == NotificationState.ALL) {
IdmNotificationLogDto childNotification = new IdmNotificationLogDto();
childNotification.setCreated(created);
childNotification.setMessage(new IdmMessageDto.Builder(NotificationLevel.SUCCESS).setSubject("mock").setMessage("mock").build());
childNotification.setParent(notification.getId());
childNotification.setSent(created);
//
service.save(childNotification);
}
//
return notification;
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto 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.IdmNotificationLogDto 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());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto in project CzechIdMng by bcvsolutions.
the class DefaultRptReportManagerIntegrationTest method testNotSendNotConfiguredNotificationAfterEnd.
@Test
public void testNotSendNotConfiguredNotificationAfterEnd() throws Exception {
IdmIdentityDto identity = getHelper().createIdentity();
//
try {
// report is sent to logged identity by default
getHelper().login(identity);
//
RptReportDto report = new RptReportDto();
report.setExecutorName(TestReportExecutor.REPORT_NAME);
IdmFormDto filter = new IdmFormDto();
TestReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestReportExecutor.class);
IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
IdmFormValueDto topic = new IdmFormValueDto(definition.getMappedAttributeByCode(AbstractReportExecutor.PROPERTY_TOPIC_REPORT_GENERATE_SUCCESS));
filter.getValues().add(topic);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
report = manager.generate(report);
UUID reportId = report.getId();
Assert.assertNotNull(reportId);
Assert.assertNotNull(report.getData());
//
try (InputStream is = attachmentManager.getAttachmentData(report.getData())) {
Assert.assertEquals(mapper.writeValueAsString(TestReportExecutor.identities), IOUtils.toString(is));
}
reportService.delete(report);
attachmentManager.deleteAttachments(report);
//
// test notification is sent
IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
notificationFilter.setRecipient(identity.getUsername());
notificationFilter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationService.find(notificationFilter, null).getContent();
Assert.assertTrue(notifications.isEmpty());
} finally {
logout();
}
}
Aggregations