Search in sources :

Example 26 with IdmFormProjectionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityProjectionManagerIntegrationTest method testValidateExtendedAttributeMinFailed.

@Transactional
@Test(expected = InvalidFormException.class)
public void testValidateExtendedAttributeMinFailed() throws Exception {
    // prepare projection
    IdmFormProjectionDto formProjection = new IdmFormProjectionDto();
    formProjection.setCode(getHelper().createName());
    formProjection.setOwnerType(lookupService.getOwnerType(IdmIdentityDto.class));
    formProjection.getProperties().put(IdentityFormProjectionRoute.PARAMETER_ALL_CONTRACTS, true);
    // 
    IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
    attributeDefinitionOne.setCode(getHelper().createName());
    attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
    attributeDefinitionOne.setPersistentType(PersistentType.SHORTTEXT);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attributeDefinitionOne));
    attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
    // 
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    attribute.setId(attributeDefinitionOne.getId());
    attribute.setPersistentType(attributeDefinitionOne.getPersistentType());
    attribute.setFormDefinition(attributeDefinitionOne.getFormDefinition());
    attribute.setCode(attributeDefinitionOne.getCode());
    attribute.setRequired(true);
    attribute.setLabel("overriden");
    attribute.setPlaceholder("overriden");
    attribute.setMin(BigDecimal.TEN);
    attribute.setMax(BigDecimal.TEN);
    attribute.setRegex("[abc]");
    attribute.setValidationMessage("Test validation failed.");
    formProjection.setFormValidations(mapper.writeValueAsString(Lists.newArrayList(attribute)));
    formProjection = projectionService.save(formProjection);
    // 
    // create identity with projection is defined
    IdmIdentityDto identity = new IdmIdentityDto(getHelper().createName());
    identity.setExternalCode(getHelper().createName());
    identity.setLastName(getHelper().createName());
    identity.setFormProjection(formProjection.getId());
    // 
    // set eav
    IdmFormInstanceDto instanceOne = new IdmFormInstanceDto();
    instanceOne.setFormDefinition(formDefinitionOne);
    IdmFormValueDto valueOne = new IdmFormValueDto(attribute);
    valueOne.setValue("abc");
    instanceOne.setValues(Lists.newArrayList(valueOne));
    identity.setEavs(Lists.newArrayList(instanceOne));
    // 
    IdmIdentityProjectionDto projection = new IdmIdentityProjectionDto(identity);
    // 
    IdentityProjectionEvent identityProjectionEvent = new IdentityProjectionEvent(IdentityProjectionEventType.CREATE, projection);
    identityProjectionEvent.setPriority(PriorityType.IMMEDIATE);
    manager.publish(identityProjectionEvent);
}
Also used : IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdentityProjectionEvent(eu.bcvsolutions.idm.core.eav.api.event.IdentityProjectionEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityProjectionDto(eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with IdmFormProjectionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityProjectionManagerIntegrationTest method testAssignAutomaticRoleIdentityAndContractEav.

@Test
public void testAssignAutomaticRoleIdentityAndContractEav() throws Exception {
    UUID identityId = null;
    try {
        getHelper().enableAsynchronousProcessing();
        // create form definition, roles, automatic role etc.
        IdmRoleDto role = getHelper().createRole();
        IdmRoleDto subRole = getHelper().createRole();
        getHelper().createRoleComposition(role, subRole);
        IdmRoleDto roleContract = getHelper().createRole();
        IdmRoleDto subRoleContract = getHelper().createRole();
        getHelper().createRoleComposition(roleContract, subRoleContract);
        // 
        IdmFormAttributeDto formAttributeOne = new IdmFormAttributeDto(getHelper().createName());
        IdmFormDefinitionDto formDefinition = formService.createDefinition(IdmIdentityDto.class, getHelper().createName(), Lists.newArrayList(formAttributeOne));
        formAttributeOne = formDefinition.getMappedAttributeByCode(formAttributeOne.getCode());
        // 
        IdmFormAttributeDto formAttributeContract = new IdmFormAttributeDto(getHelper().createName());
        IdmFormDefinitionDto formDefinitionContract = formService.createDefinition(IdmIdentityContractDto.class, getHelper().createName(), Lists.newArrayList(formAttributeContract));
        formAttributeContract = formDefinitionContract.getMappedAttributeByCode(formAttributeContract.getCode());
        // 
        IdmAutomaticRoleAttributeDto automaticRole = getHelper().createAutomaticRole(role.getId());
        getHelper().createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY_EAV, null, formAttributeOne.getId(), "mockOne");
        IdmAutomaticRoleAttributeDto automaticRoleContract = getHelper().createAutomaticRole(roleContract.getId());
        getHelper().createAutomaticRoleRule(automaticRoleContract.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.CONTRACT_EAV, null, formAttributeContract.getId(), "mockContract");
        // form projection
        IdmFormProjectionDto formProjection = new IdmFormProjectionDto();
        formProjection.setCode(getHelper().createName());
        formProjection.setOwnerType(lookupService.getOwnerType(IdmIdentityDto.class));
        formProjection.getProperties().put(IdentityFormProjectionRoute.PARAMETER_LOAD_ASSIGNED_ROLES, false);
        formProjection.getProperties().put(IdentityFormProjectionRoute.PARAMETER_ALL_CONTRACTS, true);
        FormDefinitionAttributes attributes = new FormDefinitionAttributes();
        attributes.setDefinition(formDefinition.getId());
        attributes.getAttributes().add(formAttributeOne.getId());
        FormDefinitionAttributes attributesContract = new FormDefinitionAttributes();
        attributesContract.setDefinition(formDefinitionContract.getId());
        attributesContract.getAttributes().add(formAttributeContract.getId());
        formProjection.setCode(getHelper().createName());
        formProjection.setOwnerType(lookupService.getOwnerType(IdmIdentityDto.class));
        formProjection.setFormDefinitions(mapper.writeValueAsString(Lists.newArrayList(attributes, attributesContract)));
        formProjection = projectionService.save(formProjection);
        // 
        // prepare identity projection with two contract
        IdmIdentityDto identity = new IdmIdentityDto(getHelper().createName());
        identity.setFormProjection(formProjection.getId());
        IdmFormValueDto formValue = new IdmFormValueDto(formAttributeOne);
        formValue.setValue("mockOne");
        identity.getEavs().add(new IdmFormInstanceDto(identity, formDefinition, Lists.newArrayList(formValue)));
        IdmIdentityContractDto contractOne = new IdmIdentityContractDto();
        contractOne.setPosition(getHelper().createName());
        IdmIdentityContractDto contractTwo = new IdmIdentityContractDto();
        contractTwo.setPosition(getHelper().createName());
        IdmFormValueDto formValueContract = new IdmFormValueDto(formAttributeContract);
        formValueContract.setValue("mockContract");
        contractTwo.getEavs().add(new IdmFormInstanceDto(contractTwo, formDefinitionContract, Lists.newArrayList(formValueContract)));
        IdmIdentityProjectionDto projection = new IdmIdentityProjectionDto(identity);
        projection.setContract(contractOne);
        projection.setOtherContracts(Lists.newArrayList(contractTwo));
        // 
        // create by projection
        projection = manager.publish(new IdentityProjectionEvent(IdentityProjectionEventType.CREATE, projection)).getContent();
        IdmIdentityProjectionDto createdProjection = manager.get(projection);
        identityId = createdProjection.getIdentity().getId();
        Assert.assertEquals(identity.getUsername(), createdProjection.getIdentity().getUsername());
        IdmIdentityContractDto primeContract = createdProjection.getContract();
        Assert.assertNotNull(primeContract);
        Assert.assertEquals(contractOne.getPosition(), primeContract.getPosition());
        Assert.assertEquals(1, createdProjection.getOtherContracts().size());
        IdmIdentityContractDto otherContract = createdProjection.getOtherContracts().get(0);
        Assert.assertEquals(contractTwo.getPosition(), otherContract.getPosition());
        // 
        // 6 roles
        IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
        filter.setIdentityId(createdProjection.getIdentity().getId());
        getHelper().waitForResult(res -> {
            return identityRoleService.find(filter, null).getContent().size() != 6;
        });
        List<IdmIdentityRoleDto> identityRoles = Lists.newArrayList(identityRoleService.find(filter, null).getContent());
        Assert.assertEquals(6, identityRoles.size());
        Assert.assertEquals(2, identityRoles.stream().filter(ir -> ir.getRole().equals(role.getId())).count());
        Assert.assertEquals(2, identityRoles.stream().filter(ir -> ir.getRole().equals(subRole.getId())).count());
        Assert.assertEquals(1, identityRoles.stream().filter(ir -> ir.getRole().equals(roleContract.getId())).count());
        Assert.assertEquals(1, identityRoles.stream().filter(ir -> ir.getRole().equals(subRoleContract.getId())).count());
        // 
        // change eav value => remove all automatic roles
        formValue.setValue("mockUpdate");
        createdProjection.getIdentity().getEavs().clear();
        createdProjection.getIdentity().getEavs().add(new IdmFormInstanceDto(identity, formDefinition, Lists.newArrayList(formValue)));
        manager.publish(new IdentityProjectionEvent(IdentityProjectionEventType.UPDATE, createdProjection)).getContent();
        getHelper().waitForResult(res -> {
            return identityRoleService.find(filter, null).getContent().size() != 2;
        });
        // 
        identityRoles = Lists.newArrayList(identityRoleService.find(filter, null).getContent());
        Assert.assertEquals(2, identityRoles.size());
        Assert.assertEquals(1, identityRoles.stream().filter(ir -> ir.getRole().equals(roleContract.getId())).count());
        Assert.assertEquals(1, identityRoles.stream().filter(ir -> ir.getRole().equals(subRoleContract.getId())).count());
    } finally {
        getHelper().disableAsynchronousProcessing();
        getHelper().deleteIdentity(identityId);
    }
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) IdmIdentityProjectionDto(eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto) IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdentityProjectionEvent(eu.bcvsolutions.idm.core.eav.api.event.IdentityProjectionEvent) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Example 28 with IdmFormProjectionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityProjectionManagerIntegrationTest method testValidateExtendedAttributeIsDeleted.

@Test
@Transactional
public void testValidateExtendedAttributeIsDeleted() throws Exception {
    // prepare projection
    IdmFormProjectionDto formProjection = new IdmFormProjectionDto();
    formProjection.setCode(getHelper().createName());
    formProjection.setOwnerType(lookupService.getOwnerType(IdmIdentityDto.class));
    formProjection.getProperties().put(IdentityFormProjectionRoute.PARAMETER_ALL_CONTRACTS, true);
    // 
    IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
    attributeDefinitionOne.setCode(getHelper().createName());
    attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
    attributeDefinitionOne.setPersistentType(PersistentType.SHORTTEXT);
    IdmFormAttributeDto attributeDefinitionTwo = new IdmFormAttributeDto();
    attributeDefinitionTwo.setCode(getHelper().createName());
    attributeDefinitionTwo.setName(attributeDefinitionOne.getCode());
    attributeDefinitionTwo.setPersistentType(PersistentType.SHORTTEXT);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attributeDefinitionOne, attributeDefinitionTwo));
    attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
    attributeDefinitionTwo = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionTwo.getCode());
    // 
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    attribute.setId(attributeDefinitionOne.getId());
    attribute.setPersistentType(attributeDefinitionOne.getPersistentType());
    attribute.setFormDefinition(attributeDefinitionOne.getFormDefinition());
    attribute.setCode(attributeDefinitionOne.getCode());
    attribute.setRequired(true);
    attribute.setLabel("overriden");
    attribute.setPlaceholder("overriden");
    attribute.setMin(BigDecimal.TEN);
    attribute.setMax(BigDecimal.TEN);
    attribute.setRegex("[abc]");
    attribute.setValidationMessage("Test validation failed.");
    formProjection.setFormValidations(mapper.writeValueAsString(Lists.newArrayList(attribute)));
    formProjection = projectionService.save(formProjection);
    // 
    formService.deleteAttribute(attributeDefinitionOne);
    // 
    // create identity with projection is defined
    IdmIdentityDto identity = new IdmIdentityDto(getHelper().createName());
    identity.setExternalCode(getHelper().createName());
    identity.setLastName(getHelper().createName());
    identity.setFormProjection(formProjection.getId());
    // 
    // set eav
    IdmFormInstanceDto instanceOne = new IdmFormInstanceDto();
    instanceOne.setFormDefinition(formDefinitionOne);
    IdmFormValueDto valueTwo = new IdmFormValueDto(attributeDefinitionTwo);
    valueTwo.setValue("aabbaabbcc");
    instanceOne.setValues(Lists.newArrayList(valueTwo));
    identity.setEavs(Lists.newArrayList(instanceOne));
    // 
    IdmIdentityProjectionDto projection = new IdmIdentityProjectionDto(identity);
    // 
    IdentityProjectionEvent identityProjectionEvent = new IdentityProjectionEvent(IdentityProjectionEventType.CREATE, projection);
    identityProjectionEvent.setPriority(PriorityType.IMMEDIATE);
    IdmIdentityProjectionDto createdProjection = manager.publish(identityProjectionEvent).getContent();
    // 
    Assert.assertEquals(valueTwo.getValue(), createdProjection.getIdentity().getEavs().stream().filter(i -> i.getFormDefinition().getId().equals(formDefinitionOne.getId())).findFirst().get().toSinglePersistentValue(attributeDefinitionTwo.getCode()));
}
Also used : IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdentityProjectionEvent(eu.bcvsolutions.idm.core.eav.api.event.IdentityProjectionEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityProjectionDto(eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 29 with IdmFormProjectionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityProjectionManagerIntegrationTest method testValidateExtendedAttributeRegexFailed.

@Transactional
@Test(expected = InvalidFormException.class)
public void testValidateExtendedAttributeRegexFailed() throws Exception {
    // prepare projection
    IdmFormProjectionDto formProjection = new IdmFormProjectionDto();
    formProjection.setCode(getHelper().createName());
    formProjection.setOwnerType(lookupService.getOwnerType(IdmIdentityDto.class));
    formProjection.getProperties().put(IdentityFormProjectionRoute.PARAMETER_ALL_CONTRACTS, true);
    // 
    IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
    attributeDefinitionOne.setCode(getHelper().createName());
    attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
    attributeDefinitionOne.setPersistentType(PersistentType.SHORTTEXT);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attributeDefinitionOne));
    attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
    // 
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    attribute.setId(attributeDefinitionOne.getId());
    attribute.setPersistentType(attributeDefinitionOne.getPersistentType());
    attribute.setFormDefinition(attributeDefinitionOne.getFormDefinition());
    attribute.setCode(attributeDefinitionOne.getCode());
    attribute.setRequired(true);
    attribute.setLabel("overriden");
    attribute.setPlaceholder("overriden");
    attribute.setMin(BigDecimal.ONE);
    attribute.setMax(BigDecimal.TEN);
    attribute.setRegex("[abc]");
    attribute.setValidationMessage("Test validation failed.");
    formProjection.setFormValidations(mapper.writeValueAsString(Lists.newArrayList(attribute)));
    formProjection = projectionService.save(formProjection);
    // 
    // create identity with projection is defined
    IdmIdentityDto identity = new IdmIdentityDto(getHelper().createName());
    identity.setExternalCode(getHelper().createName());
    identity.setLastName(getHelper().createName());
    identity.setFormProjection(formProjection.getId());
    // 
    // set eav
    IdmFormInstanceDto instanceOne = new IdmFormInstanceDto();
    instanceOne.setFormDefinition(formDefinitionOne);
    IdmFormValueDto valueOne = new IdmFormValueDto(attribute);
    valueOne.setValue("abcd");
    instanceOne.setValues(Lists.newArrayList(valueOne));
    identity.setEavs(Lists.newArrayList(instanceOne));
    // 
    IdmIdentityProjectionDto projection = new IdmIdentityProjectionDto(identity);
    // 
    IdentityProjectionEvent identityProjectionEvent = new IdentityProjectionEvent(IdentityProjectionEventType.CREATE, projection);
    identityProjectionEvent.setPriority(PriorityType.IMMEDIATE);
    manager.publish(identityProjectionEvent);
}
Also used : IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdentityProjectionEvent(eu.bcvsolutions.idm.core.eav.api.event.IdentityProjectionEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityProjectionDto(eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with IdmFormProjectionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityProjectionManagerIntegrationTest method testLoadProjectionDefinedEavsOnly.

@Test
@Transactional
public void testLoadProjectionDefinedEavsOnly() throws Exception {
    // 
    // create definition with two attributes
    IdmFormAttributeDto formAttributeOne = new IdmFormAttributeDto(getHelper().createName());
    IdmFormAttributeDto formAttributeTwo = new IdmFormAttributeDto(getHelper().createName());
    IdmFormDefinitionDto formDefinition = formService.createDefinition(IdmIdentityDto.class, getHelper().createName(), Lists.newArrayList(formAttributeOne, formAttributeTwo));
    formAttributeOne = formDefinition.getMappedAttributeByCode(formAttributeOne.getCode());
    formAttributeTwo = formDefinition.getMappedAttributeByCode(formAttributeTwo.getCode());
    // 
    // create projection with one attribute
    FormDefinitionAttributes attributes = new FormDefinitionAttributes();
    attributes.setDefinition(formDefinition.getId());
    attributes.getAttributes().add(formAttributeOne.getId());
    IdmFormProjectionDto projection = new IdmFormProjectionDto();
    projection.setCode(getHelper().createName());
    projection.setOwnerType(lookupService.getOwnerType(IdmIdentityDto.class));
    projection.setFormDefinitions(mapper.writeValueAsString(Lists.newArrayList(attributes)));
    projection = projectionService.save(projection);
    // 
    // create identity with projection is defined
    IdmIdentityDto identity = new IdmIdentityDto(getHelper().createName());
    identity.setFormProjection(projection.getId());
    identity = identityService.save(identity);
    // 
    // save some values
    IdmFormValueDto formValueOne = new IdmFormValueDto(formAttributeOne);
    formValueOne.setValue(getHelper().createName());
    IdmFormValueDto formValueTwo = new IdmFormValueDto(formAttributeTwo);
    formValueTwo.setValue(getHelper().createName());
    List<IdmFormValueDto> formValues = Lists.newArrayList(formValueOne, formValueTwo);
    identity.setEavs(Lists.newArrayList(new IdmFormInstanceDto(identity, formDefinition, formValues)));
    manager.publish(new IdentityProjectionEvent(IdentityProjectionEventType.UPDATE, new IdmIdentityProjectionDto(identity)));
    // 
    IdmIdentityProjectionDto identityProjection = manager.get(identity.getId());
    // 
    Assert.assertEquals(1, identityProjection.getIdentity().getEavs().size());
    Assert.assertEquals(1, identityProjection.getIdentity().getEavs().get(0).getValues().size());
    Assert.assertEquals(formValueOne.getValue(), identityProjection.getIdentity().getEavs().get(0).getValues().get(0).getValue());
}
Also used : IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdentityProjectionEvent(eu.bcvsolutions.idm.core.eav.api.event.IdentityProjectionEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) IdmIdentityProjectionDto(eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmFormProjectionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto)36 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)30 Test (org.junit.Test)21 IdmIdentityProjectionDto (eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto)17 Transactional (org.springframework.transaction.annotation.Transactional)16 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)13 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)12 IdentityProjectionEvent (eu.bcvsolutions.idm.core.eav.api.event.IdentityProjectionEvent)12 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)12 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)10 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)10 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)8 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)6 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)6 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 UUID (java.util.UUID)4 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)3