Search in sources :

Example 26 with IdmNotificationFilter

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

the class IdentityMonitoredFieldsProcessorTest method changeNotMonitoredFieldTest.

@Test
public void changeNotMonitoredFieldTest() {
    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.notEmpty(recipients, "Test need some recipients");
    // Test before notify
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(recipients.get(0).getUsername());
    String changedValue = "changed" + UUID.randomUUID();
    // We change not monitored fields
    identity.setLastName(changedValue);
    identity.setDescription(changedValue);
    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());
    // No notification should be sent
    assertEquals(0, notifications.size());
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) InitTestData(eu.bcvsolutions.idm.InitTestData) 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.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Assert(org.springframework.util.Assert) 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 27 with IdmNotificationFilter

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

the class ProvisioningBreakProcessorTest method testGlobalConfigurationDisable.

@Test
public void testGlobalConfigurationDisable() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    IdmIdentityDto identity = testHelper.createIdentity();
    IdmIdentityDto recipient = testHelper.createIdentity();
    // 
    // create global configuration
    createGlobalConfiguration(ProvisioningBreakConfiguration.GLOBAL_BREAK_UPDATE_OPERATION, false, null, 2, 20l, recipient, null);
    // 
    this.createAccount(system, identity);
    // 
    // create
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity);
    // block
    provisioningService.doProvisioning(identity);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(recipient.getUsername());
    List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
    // two notification (notification +
    assertEquals(2, content.size());
    // parent)
    // 
    system = systemService.get(system.getId());
    assertEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 28 with IdmNotificationFilter

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

the class ProvisioningBreakProcessorTest method testDisableCreateOperation.

@Test
public void testDisableCreateOperation() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    IdmIdentityDto identity = testHelper.createIdentity();
    IdmIdentityDto identity2 = testHelper.createIdentity();
    IdmIdentityDto identity3 = testHelper.createIdentity();
    SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 2, null, ProvisioningEventType.CREATE, system.getId());
    IdmIdentityDto recipient = testHelper.createIdentity();
    createRecipient(breakConfig.getId(), recipient.getId(), null);
    // 
    this.createAccount(system, identity);
    this.createAccount(system, identity2);
    this.createAccount(system, identity3);
    // 
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity2);
    provisioningService.doProvisioning(identity3);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(recipient.getUsername());
    List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
    // two notification (notification +
    assertEquals(2, content.size());
    // parent)
    // 
    system = systemService.get(system.getId());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
    assertEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) 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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmNotificationFilter

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

the class ProvisioningBreakProcessorTest method testDisableUpdateOperationWithZeroLimit.

@Test
public void testDisableUpdateOperationWithZeroLimit() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    IdmIdentityDto identity = testHelper.createIdentity();
    SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 0, null, ProvisioningEventType.UPDATE, system.getId());
    IdmIdentityDto recipient = testHelper.createIdentity();
    createRecipient(breakConfig.getId(), recipient.getId(), null);
    // 
    this.createAccount(system, identity);
    // 
    // 
    // create
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(recipient.getUsername());
    List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
    // two notification (notification +
    assertEquals(2, content.size());
    // parent)
    // 
    system = systemService.get(system.getId());
    assertEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) 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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 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.notEmpty(recipients, "Test need some recipients");
    // 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) InitTestData(eu.bcvsolutions.idm.InitTestData) 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.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Assert(org.springframework.util.Assert) 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)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