Search in sources :

Example 96 with IdmNotificationFilter

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
}
Also used : Sort(org.springframework.data.domain.Sort) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)

Example 97 with IdmNotificationFilter

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()));
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) 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) UUID(java.util.UUID) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 98 with IdmNotificationFilter

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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test) ChangeIdentityPermissionTest(eu.bcvsolutions.idm.core.workflow.permissions.ChangeIdentityPermissionTest)

Example 99 with IdmNotificationFilter

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());
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationLogRepository(eu.bcvsolutions.idm.core.notification.repository.IdmNotificationLogRepository) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) UUID(java.util.UUID) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) Collectors(java.util.stream.Collectors) IdmNotificationLog(eu.bcvsolutions.idm.core.notification.entity.IdmNotificationLog) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) List(java.util.List) IdmEmailLogRepository(eu.bcvsolutions.idm.core.notification.repository.IdmEmailLogRepository) CoreModuleDescriptor(eu.bcvsolutions.idm.core.CoreModuleDescriptor) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdentityMonitoredFieldsProcessor(eu.bcvsolutions.idm.core.model.event.processor.identity.IdentityMonitoredFieldsProcessor) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 100 with IdmNotificationFilter

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()));
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationLogRepository(eu.bcvsolutions.idm.core.notification.repository.IdmNotificationLogRepository) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) UUID(java.util.UUID) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) Collectors(java.util.stream.Collectors) IdmNotificationLog(eu.bcvsolutions.idm.core.notification.entity.IdmNotificationLog) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) List(java.util.List) IdmEmailLogRepository(eu.bcvsolutions.idm.core.notification.repository.IdmEmailLogRepository) CoreModuleDescriptor(eu.bcvsolutions.idm.core.CoreModuleDescriptor) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdentityMonitoredFieldsProcessor(eu.bcvsolutions.idm.core.model.event.processor.identity.IdentityMonitoredFieldsProcessor) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)100 Test (org.junit.Test)97 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)89 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)80 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)65 List (java.util.List)37 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)34 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)33 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)31 ZonedDateTime (java.time.ZonedDateTime)31 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)29 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)26 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)26 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)26 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)25 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)23 UUID (java.util.UUID)17 Transactional (org.springframework.transaction.annotation.Transactional)16 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)14