Search in sources :

Example 1 with Assert.assertEquals

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

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDiffPriorityTest.

@Test
@Transactional
public void compileAttributesOverrloadedDiffPriorityTest() {
    List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
    List<AttributeMapping> defaultAttributes = new ArrayList<>();
    initDataSystem();
    initOverloadedAttributes(overloadingAttributes, defaultAttributes);
    // roleOne
    SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
    IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
    roleDto.setPriority(200);
    roleDto = roleService.save(roleDto);
    // roleTwo
    SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
    roleDto = roleService.get(roleSystem2.getRole());
    roleDto.setPriority(100);
    roleDto = roleService.save(roleDto);
    List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
    Assert.assertEquals(2, compilledAttributes.size());
    Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
        return "defOneOverloaded".equals(attribute.getName());
    }).findFirst().isPresent());
}
Also used : MethodSorters(org.junit.runners.MethodSorters) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIdentityRepository(eu.bcvsolutions.idm.core.model.repository.IdmIdentityRepository) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) 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) After(org.junit.After) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FixMethodOrder(org.junit.FixMethodOrder) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ArrayList(java.util.ArrayList) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) InitApplicationData(eu.bcvsolutions.idm.InitApplicationData) 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) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmTreeTypeService(eu.bcvsolutions.idm.core.api.service.IdmTreeTypeService) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) 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) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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_) 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) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Assert.assertEquals

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

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDisabledTest.

@Test
@Transactional
public void compileAttributesOverrloadedDisabledTest() {
    List<AttributeMapping> defaultAttributes = new ArrayList<>();
    List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
    initDataSystem();
    SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
    attOne.setName("attOne");
    attOne.setObjectClass(objectClasses.get(0).getId());
    attOne.setClassType(String.class.getName());
    attOne = schemaAttributeService.save(attOne);
    SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
    attTwo.setName("attTwo");
    attTwo.setObjectClass(objectClasses.get(0).getId());
    attTwo.setClassType(String.class.getName());
    attTwo = schemaAttributeService.save(attTwo);
    SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
    defOne.setEntityAttribute(true);
    defOne.setIdmPropertyName("one");
    defOne.setName("defOne");
    defOne.setDisabledAttribute(true);
    defOne.setSchemaAttribute(attOne.getId());
    defOne.setSystemMapping(systemMapping.getId());
    defOne = systemAttributeMappingService.save(defOne);
    defaultAttributes.add(defOne);
    SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
    defTwo.setEntityAttribute(true);
    defTwo.setIdmPropertyName("two");
    defTwo.setName("defTwo");
    defTwo.setSchemaAttribute(attTwo.getId());
    defTwo.setSystemMapping(systemMapping.getId());
    defTwo = systemAttributeMappingService.save(defTwo);
    defaultAttributes.add(defTwo);
    IdmRoleDto roleOne = new IdmRoleDto();
    roleOne.setName("roleOne");
    roleOne.setPriority(100);
    roleOne = roleService.save(roleOne);
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setRole(roleOne.getId());
    roleSystem.setSystem(system.getId());
    roleSystem.setSystemMapping(systemMapping.getId());
    roleSystem = roleSystemService.save(roleSystem);
    SysRoleSystemAttributeDto overloadedOne = new SysRoleSystemAttributeDto();
    overloadedOne.setSystemAttributeMapping(defOne.getId());
    overloadedOne.setEntityAttribute(true);
    overloadedOne.setIdmPropertyName("one");
    overloadedOne.setName("defOneOverloaded");
    overloadedOne.setDisabledDefaultAttribute(false);
    overloadedOne.setRoleSystem(roleSystem.getId());
    overloadedOne = roleSystemAttributeService.save(overloadedOne);
    overloadingAttributes.add(overloadedOne);
    List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
    Assert.assertEquals(2, compilledAttributes.size());
    Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
        return "defOneOverloaded".equals(attribute.getName());
    }).findFirst().isPresent());
}
Also used : MethodSorters(org.junit.runners.MethodSorters) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIdentityRepository(eu.bcvsolutions.idm.core.model.repository.IdmIdentityRepository) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) 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) After(org.junit.After) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FixMethodOrder(org.junit.FixMethodOrder) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ArrayList(java.util.ArrayList) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) InitApplicationData(eu.bcvsolutions.idm.InitApplicationData) 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) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmTreeTypeService(eu.bcvsolutions.idm.core.api.service.IdmTreeTypeService) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) 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) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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_) 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) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Assert.assertEquals

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

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeAuthoDisableTest.

@Test
@Transactional
public void compileAttributesOverrloadedStrategyMergeAuthoDisableTest() {
    List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
    List<AttributeMapping> defaultAttributes = new ArrayList<>();
    initDataSystem();
    initOverloadedAttributes(overloadingAttributes, defaultAttributes);
    // roleOne
    SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
    IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
    roleDto.setPriority(200);
    roleDto = roleService.save(roleDto);
    // roleTwo
    SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
    roleDto = roleService.get(roleSystem2.getRole());
    roleDto.setPriority(500);
    roleDto = roleService.save(roleDto);
    // overloadedRoleOne
    SysRoleSystemAttributeDto attribute1 = overloadingAttributes.get(0);
    attribute1.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
    attribute1 = roleSystemAttributeService.save(attribute1);
    overloadingAttributes.set(0, attribute1);
    // overloadedRoleTwo
    SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
    attribute2.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
    attribute2.setDisabledDefaultAttribute(true);
    attribute2 = roleSystemAttributeService.save(attribute2);
    overloadingAttributes.set(1, attribute2);
    List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
    Assert.assertEquals(2, compilledAttributes.size());
    Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
        return "defOneOverloaded".equals(attribute.getName());
    }).findFirst().isPresent());
}
Also used : MethodSorters(org.junit.runners.MethodSorters) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIdentityRepository(eu.bcvsolutions.idm.core.model.repository.IdmIdentityRepository) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) 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) After(org.junit.After) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FixMethodOrder(org.junit.FixMethodOrder) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ArrayList(java.util.ArrayList) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) InitApplicationData(eu.bcvsolutions.idm.InitApplicationData) 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) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmTreeTypeService(eu.bcvsolutions.idm.core.api.service.IdmTreeTypeService) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) 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) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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_) 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) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Assert.assertEquals

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

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyCreateTest.

@Test
@Transactional
public void compileAttributesOverrloadedStrategyCreateTest() {
    List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
    List<AttributeMapping> defaultAttributes = new ArrayList<>();
    initDataSystem();
    initOverloadedAttributes(overloadingAttributes, defaultAttributes);
    // roleOne
    SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
    IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
    roleDto.setPriority(200);
    roleDto = roleService.save(roleDto);
    // roleTwo
    SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
    roleDto = roleService.get(roleSystem2.getRole());
    roleDto.setPriority(500);
    roleDto = roleService.save(roleDto);
    // overloadedRoleOne
    SysRoleSystemAttributeDto attribute1 = overloadingAttributes.get(0);
    attribute1.setStrategyType(AttributeMappingStrategyType.CREATE);
    attribute1 = roleSystemAttributeService.save(attribute1);
    overloadingAttributes.set(0, attribute1);
    // overloadedRoleTwo
    SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
    attribute2.setStrategyType(AttributeMappingStrategyType.CREATE);
    attribute2 = roleSystemAttributeService.save(attribute2);
    overloadingAttributes.set(1, attribute2);
    List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
    Assert.assertEquals(2, compilledAttributes.size());
    Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
        return "defOneOverloadedRoleTwo".equals(attribute.getName());
    }).findFirst().isPresent());
}
Also used : MethodSorters(org.junit.runners.MethodSorters) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIdentityRepository(eu.bcvsolutions.idm.core.model.repository.IdmIdentityRepository) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) 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) After(org.junit.After) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FixMethodOrder(org.junit.FixMethodOrder) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ArrayList(java.util.ArrayList) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) InitApplicationData(eu.bcvsolutions.idm.InitApplicationData) 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) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmTreeTypeService(eu.bcvsolutions.idm.core.api.service.IdmTreeTypeService) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) 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) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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_) 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) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Assert.assertEquals

use of org.junit.Assert.assertEquals in project flow by vaadin.

the class BinderConverterValidatorTest method save_beanValidationErrorsWithConverter.

@Test(expected = ValidationException.class)
public void save_beanValidationErrorsWithConverter() throws ValidationException {
    Binder<Person> binder = new Binder<>();
    binder.forField(ageField).withConverter(new StringToIntegerConverter("Can't convert")).bind(Person::getAge, Person::setAge);
    binder.withValidator(Validator.from(person -> false, "b"));
    Person person = new Person();
    ageField.setValue("1");
    try {
        binder.writeBean(person);
    } finally {
        // Bean should have been updated for item validation but reverted
        Assert.assertEquals(0, person.getAge());
    }
}
Also used : HasValue(com.vaadin.flow.component.HasValue) Person(com.vaadin.flow.tests.data.bean.Person) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Label(com.vaadin.flow.component.html.Label) HashMap(java.util.HashMap) Assert.assertThat(org.junit.Assert.assertThat) HasValidation(com.vaadin.flow.component.HasValidation) Map(java.util.Map) Matchers.hasSize(org.hamcrest.Matchers.hasSize) BindingBuilder(com.vaadin.flow.data.binder.Binder.BindingBuilder) SerializablePredicate(com.vaadin.flow.function.SerializablePredicate) Before(org.junit.Before) StringToIntegerConverter(com.vaadin.flow.data.converter.StringToIntegerConverter) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test) Serializable(java.io.Serializable) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) NotEmptyValidator(com.vaadin.flow.data.validator.NotEmptyValidator) Assert(org.junit.Assert) Binding(com.vaadin.flow.data.binder.Binder.Binding) TestTextField(com.vaadin.flow.data.binder.testcomponents.TestTextField) Assert.assertEquals(org.junit.Assert.assertEquals) StringToIntegerConverter(com.vaadin.flow.data.converter.StringToIntegerConverter) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Aggregations

Assert.assertEquals (org.junit.Assert.assertEquals)60 Assert (org.junit.Assert)59 Test (org.junit.Test)54 List (java.util.List)48 Before (org.junit.Before)38 ArrayList (java.util.ArrayList)37 Assert.assertTrue (org.junit.Assert.assertTrue)33 Assert.assertFalse (org.junit.Assert.assertFalse)31 Arrays (java.util.Arrays)29 Collections (java.util.Collections)28 Assert.assertNotNull (org.junit.Assert.assertNotNull)24 HashMap (java.util.HashMap)23 Map (java.util.Map)23 Collectors (java.util.stream.Collectors)22 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)19 After (org.junit.After)19 Set (java.util.Set)17 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)14 Assert.fail (org.junit.Assert.fail)14