Search in sources :

Example 6 with Assert.assertNotNull

use of org.junit.Assert.assertNotNull in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleFormAttributeServiceIntegrationTest method testSubDefinitionOverrideValidationReqex.

@Test
public void testSubDefinitionOverrideValidationReqex() {
    String regex = "regex";
    // Create role with attribute (include the sub-definition)
    IdmRoleDto role = createRoleWithAttributes();
    IdmRoleFormAttributeFilter filter = new IdmRoleFormAttributeFilter();
    filter.setRole(role.getId());
    List<IdmRoleFormAttributeDto> list = roleFormAttributeService.find(filter, null).getContent();
    Assert.assertEquals(2, list.size());
    IdmFormDefinitionDto formAttributeSubdefinition = roleService.getFormAttributeSubdefinition(role);
    Assert.assertEquals(2, formAttributeSubdefinition.getFormAttributes().size());
    // Set regex validation on false to IP attribute in the sub-definition
    list.stream().filter(roleFormAttributeDto -> {
        IdmFormAttributeDto formAttributeDto = DtoUtils.getEmbedded(roleFormAttributeDto, IdmRoleFormAttribute_.formAttribute.getName(), IdmFormAttributeDto.class);
        return formAttributeDto.getCode().equals(IP);
    }).forEach(roleFormAttributeDto -> {
        Assert.assertNull(roleFormAttributeDto.getRegex());
        roleFormAttributeDto.setRegex(regex);
        roleFormAttributeService.save(roleFormAttributeDto);
    });
    // Load sub-definition by role
    formAttributeSubdefinition = roleService.getFormAttributeSubdefinition(role);
    Assert.assertEquals(2, formAttributeSubdefinition.getFormAttributes().size());
    IdmFormAttributeDto ipFormAttribute = formAttributeSubdefinition.getFormAttributes().stream().filter(attributeDto -> {
        return attributeDto.getCode().equals(IP);
    }).findFirst().orElse(null);
    Assert.assertNotNull(ipFormAttribute);
    Assert.assertEquals(regex, ipFormAttribute.getRegex());
}
Also used : IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) IdmConceptRoleRequestService(eu.bcvsolutions.idm.core.api.service.IdmConceptRoleRequestService) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) BigDecimal(java.math.BigDecimal) Lists(com.google.common.collect.Lists) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityRole(eu.bcvsolutions.idm.core.model.entity.IdmIdentityRole) ImmutableList(com.google.common.collect.ImmutableList) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Test(org.junit.Test) RoleRequestState(eu.bcvsolutions.idm.core.api.domain.RoleRequestState) IdmRoleFormAttributeService(eu.bcvsolutions.idm.core.api.service.IdmRoleFormAttributeService) Serializable(java.io.Serializable) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) LocalDate(java.time.LocalDate) Assert(org.junit.Assert) ConceptRoleRequestOperation(eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation) Assert.assertEquals(org.junit.Assert.assertEquals) IdmRoleFormAttribute_(eu.bcvsolutions.idm.core.model.entity.IdmRoleFormAttribute_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with Assert.assertNotNull

use of org.junit.Assert.assertNotNull in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceIntegrationTest method testFillTransactionalIdCreateIdentity.

@Test
public void testFillTransactionalIdCreateIdentity() {
    // start transaction
    TransactionContextHolder.setContext(TransactionContextHolder.createEmptyContext());
    UUID transactionId = TransactionContextHolder.getContext().getTransactionId();
    Assert.assertNotNull(transactionId);
    // 
    // with password
    IdmIdentityDto identity = getHelper().createIdentity();
    Assert.assertEquals(transactionId, identity.getTransactionId());
    // default contract and password has to have the same transaction id
    IdmIdentityContractDto contract = getHelper().getPrimeContract(identity);
    Assert.assertEquals(transactionId, contract.getTransactionId());
    // default password
    IdmPasswordDto password = getHelper().getPassword(identity);
    Assert.assertEquals(transactionId, password.getTransactionId());
    // audit for identity, contract and password with the same transaction id
    IdmAuditFilter filter = new IdmAuditFilter();
    filter.setTransactionId(transactionId);
    List<IdmAuditDto> audits = auditService.find(filter, null).getContent();
    Assert.assertEquals(3, audits.size());
    // 
    Assert.assertTrue(audits.stream().anyMatch(a -> a.getEntityId().equals(identity.getId())));
    Assert.assertTrue(audits.stream().anyMatch(a -> a.getEntityId().equals(contract.getId())));
    Assert.assertTrue(audits.stream().anyMatch(a -> a.getEntityId().equals(password.getId())));
}
Also used : IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Map(java.util.Map) IdmIdentityFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmIdentityFormValue) TransactionContextHolder(eu.bcvsolutions.idm.core.api.domain.TransactionContextHolder) Assert.fail(org.junit.Assert.fail) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) PageRequest(org.springframework.data.domain.PageRequest) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Serializable(java.io.Serializable) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) List(java.util.List) IdmAuthenticationException(eu.bcvsolutions.idm.core.security.api.exception.IdmAuthenticationException) RevisionType(org.hibernate.envers.RevisionType) IdmAuditService(eu.bcvsolutions.idm.core.api.audit.service.IdmAuditService) Assert.assertFalse(org.junit.Assert.assertFalse) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallback(org.springframework.transaction.support.TransactionCallback) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmProfile(eu.bcvsolutions.idm.core.model.entity.IdmProfile) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) IdmContractGuarantee(eu.bcvsolutions.idm.core.model.entity.IdmContractGuarantee) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) Lists(com.google.common.collect.Lists) BaseEntity(eu.bcvsolutions.idm.core.api.entity.BaseEntity) IdmAuditEntityDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditEntityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AuthenticationManager(eu.bcvsolutions.idm.core.security.api.authentication.AuthenticationManager) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmProfileDto(eu.bcvsolutions.idm.core.api.dto.IdmProfileDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) Assert.assertNull(org.junit.Assert.assertNull) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with Assert.assertNotNull

use of org.junit.Assert.assertNotNull in project CzechIdMng by bcvsolutions.

the class IdentityPasswordProvisioningTest method testSendPasswordNotificationGreenLine.

@Test
public void testSendPasswordNotificationGreenLine() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
    Assert.assertNotNull(account);
    Assert.assertFalse(account.isInProtection());
    TestResource entityOnSystem = helper.findResource(account.getUid());
    assertNotNull(entityOnSystem);
    assertEquals(DEFAULT_PASSWORD, entityOnSystem.getPassword());
    // Check for send password notification
    IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
    notificationFilter.setTopic(AccModuleDescriptor.TOPIC_NEW_PASSWORD);
    notificationFilter.setRecipient(identity.getUsername());
    List<IdmNotificationLogDto> notifications = // 
    notificationLogService.find(notificationFilter, null).getContent().stream().filter(// 
    notification -> "email".equals(notification.getType())).collect(Collectors.toList());
    assertEquals(1, notifications.size());
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) After(org.junit.After) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) Collectors(java.util.stream.Collectors) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState) Serializable(java.io.Serializable) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityProvisioningExecutor(eu.bcvsolutions.idm.acc.service.impl.IdentityProvisioningExecutor) Entry(java.util.Map.Entry) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) Before(org.junit.Before) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) Assert.assertNull(org.junit.Assert.assertNull) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmEmailLog(eu.bcvsolutions.idm.core.notification.entity.IdmEmailLog) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert.assertEquals(org.junit.Assert.assertEquals) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with Assert.assertNotNull

use of org.junit.Assert.assertNotNull in project CzechIdMng by bcvsolutions.

the class IdentityPasswordProvisioningTest method testSendPasswordNotificationCreateCancelled.

@Test
public void testSendPasswordNotificationCreateCancelled() {
    // init readOnly system
    SysSystemDto system = initSystem();
    system.setReadonly(true);
    system = systemService.save(system);
    IdmRoleDto role = initRole(system);
    IdmIdentityDto identity = helper.createIdentity();
    // CREATE operation
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    // => new password is sent for valid identity only
    identity.setState(IdentityState.VALID);
    identity.setFirstName(getHelper().createName());
    // UPDATE operation
    identityService.save(identity);
    // 
    AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
    Assert.assertNotNull(account);
    TestResource entityOnSystem = helper.findResource(account.getUid());
    Assert.assertNull(entityOnSystem);
    // 
    // Check for send password notification
    IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
    notificationFilter.setTopic(AccModuleDescriptor.TOPIC_NEW_PASSWORD);
    notificationFilter.setRecipient(identity.getUsername());
    List<IdmNotificationLogDto> notifications = // 
    notificationLogService.find(notificationFilter, null).getContent().stream().filter(// 
    notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
    Assert.assertTrue(notifications.isEmpty());
    // 
    // cancel the first provisioning operation
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setEntityType(SystemEntityType.IDENTITY);
    filter.setEntityIdentifier(identity.getId());
    List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
    Assert.assertEquals(2, operations.size());
    // ~ readonly
    Assert.assertTrue(operations.stream().allMatch(o -> o.getResultState() == OperationState.NOT_EXECUTED));
    SysProvisioningOperationDto createOperation = operations.stream().filter(o -> o.getOperationType() == ProvisioningEventType.CREATE).findFirst().get();
    SysProvisioningOperationDto updateOperation = operations.stream().filter(o -> o.getOperationType() == ProvisioningEventType.UPDATE).findFirst().get();
    // 
    // active system
    system.setReadonly(false);
    system = systemService.save(system);
    // 
    // cancel the first operation
    provisioningExecutor.cancel(createOperation);
    operations = provisioningOperationService.find(filter, null).getContent();
    Assert.assertEquals(1, operations.size());
    notifications = // 
    notificationLogService.find(notificationFilter, null).getContent().stream().filter(// 
    notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
    Assert.assertTrue(notifications.isEmpty());
    // 
    provisioningExecutor.execute(updateOperation);
    operations = provisioningOperationService.find(filter, null).getContent();
    Assert.assertTrue(operations.isEmpty());
    notifications = // 
    notificationLogService.find(notificationFilter, null).getContent().stream().filter(// 
    notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
    Assert.assertEquals(1, notifications.size());
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) After(org.junit.After) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) Collectors(java.util.stream.Collectors) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState) Serializable(java.io.Serializable) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityProvisioningExecutor(eu.bcvsolutions.idm.acc.service.impl.IdentityProvisioningExecutor) Entry(java.util.Map.Entry) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) Before(org.junit.Before) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) Assert.assertNull(org.junit.Assert.assertNull) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmEmailLog(eu.bcvsolutions.idm.core.notification.entity.IdmEmailLog) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert.assertEquals(org.junit.Assert.assertEquals) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with Assert.assertNotNull

use of org.junit.Assert.assertNotNull in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method testChangeContractPositionAndValidityWithAutomaticRolesAssigned.

@Test
public void testChangeContractPositionAndValidityWithAutomaticRolesAssigned() {
    prepareAutomaticRoles();
    // 
    // prepare identity and contract
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identity.getId());
    contract.setWorkPosition(nodeD.getId());
    LocalDate validTill = LocalDate.now().plusDays(1);
    contract.setValidTill(validTill);
    contract = service.save(contract);
    // 
    // test after create
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
    IdmIdentityRoleDto automaticRole = identityRoles.stream().filter(ir -> {
        return roleA.getId().equals(ir.getRole());
    }).findFirst().orElse(null);
    Assert.assertNotNull(automaticRole);
    Assert.assertEquals(validTill, automaticRole.getValidTill());
    // 
    // => role A is the same => down recursion
    contract.setWorkPosition(nodeB.getId());
    LocalDate newValidTill = LocalDate.now().plusDays(3);
    contract.setValidTill(newValidTill);
    contract = service.save(contract);
    // 
    // test after change
    identityRoles = identityRoleService.findAllByContract(contract.getId());
    Assert.assertTrue(identityRoles.stream().anyMatch(ir -> {
        return roleA.getId().equals(ir.getRole()) && // prevent drop and create
        ir.getId().equals(automaticRole.getId()) && // validity is changed
        newValidTill.equals(ir.getValidTill());
    }));
}
Also used : Lists(org.testng.collections.Lists) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) ProcessAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessAutomaticRoleByTreeTaskExecutor) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) AutomaticRoleManager(eu.bcvsolutions.idm.core.api.service.AutomaticRoleManager) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) TransactionContextHolder(eu.bcvsolutions.idm.core.api.domain.TransactionContextHolder) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) LongRunningTaskEventType(eu.bcvsolutions.idm.core.scheduler.api.event.LongRunningTaskEvent.LongRunningTaskEventType) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) AutomaticRoleAttributeRuleType(eu.bcvsolutions.idm.core.api.domain.AutomaticRoleAttributeRuleType) RecursionType(eu.bcvsolutions.idm.core.api.domain.RecursionType) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) ContractPositionEventType(eu.bcvsolutions.idm.core.model.event.ContractPositionEvent.ContractPositionEventType) ContractState(eu.bcvsolutions.idm.core.api.domain.ContractState) IdentityContractEventType(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent.IdentityContractEventType) LongRunningFutureTask(eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask) Set(java.util.Set) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) RemoveAutomaticRoleTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.RemoveAutomaticRoleTaskExecutor) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) ContractBasePermission(eu.bcvsolutions.idm.core.security.api.domain.ContractBasePermission) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) IdentityContractEvent(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent) ContractPositionEvent(eu.bcvsolutions.idm.core.model.event.ContractPositionEvent) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmContractPositionService(eu.bcvsolutions.idm.core.api.service.IdmContractPositionService) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IdmRoleTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmRoleTreeNodeService) PermissionContext(eu.bcvsolutions.idm.core.api.dto.filter.PermissionContext) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmLongRunningTaskService(eu.bcvsolutions.idm.core.scheduler.api.service.IdmLongRunningTaskService) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Before(org.junit.Before) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) SchedulerConfiguration(eu.bcvsolutions.idm.core.scheduler.api.config.SchedulerConfiguration) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) LongRunningTaskManager(eu.bcvsolutions.idm.core.scheduler.api.service.LongRunningTaskManager) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) IdmContractGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractGuaranteeService) ApplicationContext(org.springframework.context.ApplicationContext) IdmIdentityContract_(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract_) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) PrivateIdentityConfiguration(eu.bcvsolutions.idm.core.api.config.domain.PrivateIdentityConfiguration) AutomaticRoleAttributeRuleComparison(eu.bcvsolutions.idm.core.api.domain.AutomaticRoleAttributeRuleComparison) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) IdentityConfiguration(eu.bcvsolutions.idm.core.api.config.domain.IdentityConfiguration) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Transactional(org.springframework.transaction.annotation.Transactional) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(java.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

List (java.util.List)38 Assert (org.junit.Assert)38 Assert.assertNotNull (org.junit.Assert.assertNotNull)38 Test (org.junit.Test)38 Assert.assertEquals (org.junit.Assert.assertEquals)36 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)28 Autowired (org.springframework.beans.factory.annotation.Autowired)28 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)26 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)25 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)24 FormService (eu.bcvsolutions.idm.core.eav.api.service.FormService)24 Before (org.junit.Before)24 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)23 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)23 Assert.assertTrue (org.junit.Assert.assertTrue)23 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)22 LocalDate (java.time.LocalDate)22 Assert.assertNull (org.junit.Assert.assertNull)22 Lists (com.google.common.collect.Lists)21 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)20