use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class DeleteNotificationTaskExecutor method getItemsToProcess.
@Override
public Page<IdmNotificationLogDto> getItemsToProcess(Pageable pageable) {
IdmNotificationFilter filter = new IdmNotificationFilter();
if (sentOnly) {
filter.setState(NotificationState.ALL);
filter.setSent(Boolean.TRUE);
}
if (numberOfDays > 0) {
filter.setTill(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).minusDays(numberOfDays));
}
return service.find(filter, PageRequest.of(0, pageable.getPageSize(), new Sort(Direction.ASC, IdmNotificationLog_.parent.getName())));
// new pageable is given => records are deleted and we need the first page all time
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdentityDisableBulkActionTest method checkNotification.
@Test
public void checkNotification() {
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityDisableBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 5l, null, null);
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(loginIdentity.getUsername());
filter.setNotificationType(IdmEmailLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(1, notifications.size());
IdmNotificationLogDto notificationLogDto = notifications.get(0);
assertEquals(IdmEmailLog.NOTIFICATION_TYPE, notificationLogDto.getType());
assertTrue(notificationLogDto.getMessage().getHtmlMessage().contains(bulkAction.getName()));
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class ManualWorkflowTaskDelegationBulkActionTest method testBulkActionCheckDelegateNotification.
@Test
public void testBulkActionCheckDelegateNotification() {
// Enable approving of a role-request by manager.
getHelper().setConfigurationValue(ChangeIdentityPermissionTest.APPROVE_BY_MANAGER_ENABLE, true);
IdmRoleDto roleOne = getHelper().createRole();
IdmIdentityDto delegator = getHelper().createIdentity();
IdmIdentityDto subordinate = getHelper().createIdentity();
IdmIdentityContractDto subordinateContract = getHelper().createContract(subordinate);
getHelper().createContractGuarantee(subordinateContract, delegator);
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(delegator.getUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// Assing role -> reuqest will be in progress state.
IdmRoleRequestDto roleRequest = getHelper().createRoleRequest(subordinateContract, ConceptRoleRequestOperation.ADD, roleOne);
roleRequest.setExecuteImmediately(false);
roleRequest = roleRequestService.save(roleRequest);
roleRequest = getHelper().executeRequest(roleRequest, false, true);
assertEquals(RoleRequestState.IN_PROGRESS, roleRequest.getState());
tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(1, tasks.size());
List<IdentityLinkDto> identityLinks = tasks.get(0).getIdentityLinks();
assertEquals(1, identityLinks.size());
// Task is assigned to the delegator now.
assertEquals(delegator.getId(), UUID.fromString(identityLinks.get(0).getUserId()));
IdmBulkActionDto bulkAction = this.findBulkActionForDto(WorkflowTaskInstanceAbstractDto.class, ManualWorkflowTaskDelegationBulkAction.NAME);
Set<UUID> ids = Sets.newHashSet();
ids.add(UUID.fromString(tasks.get(0).getId()));
IdmIdentityDto delegate = getHelper().createIdentity();
bulkAction.setIdentifiers(ids);
bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.DELEGATE_ATTRIBUTE, delegate.getId());
bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.CANDIDATE_OR_ASSIGNED_FILTER_FIELD, delegator.getId());
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
// Notification to the delegate should been sent.
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(delegate.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_DELEGATION_INSTANCE_CREATED_TO_DELEGATE, notifications.get(0).getTopic());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdentityMonitoredFieldsProcessorTest method sendNotificationErrorTest.
@Test(expected = ResultCodeException.class)
public void sendNotificationErrorTest() {
configurationService.setValue(PROCESSOR_KEY + "enabled", Boolean.TRUE.toString());
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_MONITORED_FIELDS, "firstName, WRONGFIELD");
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_RECIPIENTS_ROLE, "superAdminRole");
//
IdmIdentityDto identity = helper.createIdentity();
List<IdmIdentityDto> recipients = identityService.findAllByRoleName("superAdminRole");
Assert.assertFalse("Test need some recipients", recipients.isEmpty());
// Test before notify
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(recipients.get(0).getUsername());
String changedValue = "changed" + UUID.randomUUID();
identity.setFirstName(changedValue);
identityService.save(identity);
// Test after notify ... must be 0 ... processor is disabled
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent().stream().filter(notification -> {
return notification.getTopic().equals(CoreModuleDescriptor.TOPIC_IDENTITY_MONITORED_CHANGED_FIELDS);
}).collect(Collectors.toList());
//
assertEquals(0, notifications.size());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class IdentityMonitoredFieldsProcessorTest method sendNotificationTest.
@Test
public void sendNotificationTest() {
configurationService.setValue(PROCESSOR_KEY + "enabled", Boolean.TRUE.toString());
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_MONITORED_FIELDS, "firstName");
configurationService.setValue(PROCESSOR_KEY + IdentityMonitoredFieldsProcessor.PROPERTY_RECIPIENTS_ROLE, "superAdminRole");
//
IdmIdentityDto identity = helper.createIdentity();
List<IdmIdentityDto> recipients = identityService.findAllByRoleName("superAdminRole");
Assert.assertFalse("Test need some recipients", recipients.isEmpty());
// Test before notify
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setNotificationType(IdmNotificationLog.class);
filter.setRecipient(recipients.get(0).getUsername());
identity.setFirstName("changed" + UUID.randomUUID());
identity.setLastName("changed" + UUID.randomUUID());
identityService.save(identity);
// Test after notify
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent().stream().filter(notification -> {
return notification.getTopic().equals(CoreModuleDescriptor.TOPIC_IDENTITY_MONITORED_CHANGED_FIELDS);
}).collect(Collectors.toList());
assertEquals(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_IDENTITY_MONITORED_CHANGED_FIELDS, notifications.get(0).getTopic());
Assert.assertTrue(notifications.get(0).getMessage().getHtmlMessage().contains(identity.getFirstName()));
// Last name is not monitored
Assert.assertTrue(!notifications.get(0).getMessage().getHtmlMessage().contains(identity.getLastName()));
}
Aggregations