Search in sources :

Example 51 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testFillFormValues.

@Test
public void testFillFormValues() {
    FormableEntity owner = createTestOwner("test1");
    // 
    // create definition one
    IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
    attributeDefinitionOne.setCode("name_" + System.currentTimeMillis());
    attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
    attributeDefinitionOne.setPersistentType(PersistentType.TEXT);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), "t_v1", Lists.newArrayList(attributeDefinitionOne));
    attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
    // 
    // create definition two
    IdmFormAttributeDto attributeDefinitionTwo = new IdmFormAttributeDto();
    attributeDefinitionTwo.setCode("name_" + System.currentTimeMillis());
    attributeDefinitionTwo.setName(attributeDefinitionTwo.getCode());
    attributeDefinitionTwo.setPersistentType(PersistentType.TEXT);
    IdmFormDefinitionDto formDefinitionTwo = formService.createDefinition(IdmIdentity.class.getCanonicalName(), "t_v2", Lists.newArrayList(attributeDefinitionTwo));
    attributeDefinitionTwo = formDefinitionTwo.getMappedAttributeByCode(attributeDefinitionTwo.getCode());
    // 
    IdmFormValueDto value1 = new IdmFormValueDto(attributeDefinitionOne);
    value1.setValue(FORM_VALUE_ONE);
    IdmFormValueDto value2 = new IdmFormValueDto(attributeDefinitionTwo);
    value2.setValue(FORM_VALUE_TWO);
    formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1));
    formService.saveValues(owner, formDefinitionTwo, Lists.newArrayList(value2));
    assertEquals(FORM_VALUE_ONE, formService.getValues(owner, formDefinitionOne).get(0).getStringValue());
    assertEquals(FORM_VALUE_TWO, formService.getValues(owner, formDefinitionTwo).get(0).getStringValue());
    // 
    // create second owner
    FormableEntity owner2 = createTestOwner("test2");
    assertEquals(0, formService.getValues(owner2, formDefinitionOne).size());
    assertEquals(1, formService.getValues(owner, formDefinitionOne).size());
    assertEquals(1, formService.getValues(owner, formDefinitionTwo).size());
    identityService.deleteById(owner2.getId());
    assertEquals(0, formService.getValues(owner2, formDefinitionOne).size());
    assertEquals(1, formService.getValues(owner, formDefinitionOne).size());
    assertEquals(1, formService.getValues(owner, formDefinitionTwo).size());
    formService.deleteValues(owner, formDefinitionOne);
    assertEquals(0, formService.getValues(owner, formDefinitionOne).size());
    assertEquals(1, formService.getValues(owner, formDefinitionTwo).size());
    assertEquals(FORM_VALUE_TWO, formService.getValues(owner, formDefinitionTwo).get(0).getStringValue());
    identityService.deleteById(owner.getId());
    assertEquals(0, formService.getValues(owner, formDefinitionOne).size());
    assertEquals(0, formService.getValues(owner, formDefinitionTwo).size());
}
Also used : 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) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 52 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testFindTreeNodesByNullAttributeValue.

@Test
public void testFindTreeNodesByNullAttributeValue() {
    IdmTreeNodeDto owner = helper.createTreeNode();
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class);
    IdmFormAttributeDto attribute = formDefinition.getFormAttributes().get(0);
    // save values
    formService.saveValues(owner.getId(), IdmTreeNode.class, attribute, Lists.newArrayList(FORM_VALUE_ONE));
    // 
    Page<? extends Identifiable> owners = formService.findOwners(IdmTreeNode.class, attribute, FORM_VALUE_ONE, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(owner.getId(), owners.getContent().get(0).getId());
    // 
    owners = formService.findOwners(IdmTreeNode.class, attribute.getCode(), null, null);
    assertEquals(0, owners.getTotalElements());
}
Also used : IdmTreeNode(eu.bcvsolutions.idm.core.model.entity.IdmTreeNode) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 53 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testFindOwnersByMultiStringAttributeValue.

@Test
public void testFindOwnersByMultiStringAttributeValue() {
    FormableEntity owner = createTestOwner("test12");
    FormableEntity ownerTwo = createTestOwner("test13");
    FormableEntity ownerThree = createTestOwner("test14");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW);
    // save values
    formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
    formService.saveValues(ownerTwo, attribute, Lists.newArrayList(FORM_VALUE_THREE, FORM_VALUE_TWO));
    formService.saveValues(ownerThree, attribute, Lists.newArrayList(FORM_VALUE_FOUR, FORM_VALUE_FOUR));
    // 
    Page<? extends Identifiable> owners = formService.findOwners(owner.getClass(), attribute, FORM_VALUE_ONE, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(owner.getId(), owners.getContent().get(0).getId());
    // 
    owners = formService.findOwners(owner.getClass(), attribute.getCode(), FORM_VALUE_TWO, null);
    assertEquals(2, owners.getTotalElements());
    // 
    owners = formService.findOwners(owner.getClass(), attribute, FORM_VALUE_FOUR, null);
    assertEquals(1, owners.getTotalElements());
    // 
    identityService.deleteById(owner.getId());
    identityService.deleteById(ownerTwo.getId());
    identityService.deleteById(ownerThree.getId());
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 54 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testFindAttribute.

@Test
public void testFindAttribute() {
    IdmFormAttributeDto attribute = formService.getAttribute(IdmIdentity.class, InitDemoData.FORM_ATTRIBUTE_DATETIME);
    // 
    assertNotNull(attribute);
    assertEquals(PersistentType.DATETIME, attribute.getPersistentType());
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 55 with IdmFormAttributeDto

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

the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testAssingByContractEavAttrWithoutRecalcualte.

@Test
public void testAssingByContractEavAttrWithoutRecalcualte() {
    String testValue = "123!@#" + System.currentTimeMillis();
    IdmIdentityDto identity = testHelper.createIdentity();
    IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
    // 
    IdmFormAttributeDto createEavAttribute = testHelper.createEavAttribute("testingEav" + System.currentTimeMillis(), IdmIdentityContract.class, PersistentType.SHORTTEXT);
    // 
    IdmRoleDto role = testHelper.createRole();
    IdmAutomaticRoleAttributeDto automaticRole = testHelper.createAutomaticRole(role.getId());
    testHelper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.CONTRACT_EAV, null, createEavAttribute.getId(), testValue);
    // 
    primeContract.setPosition(testValue);
    primeContract = identityContractService.save(primeContract);
    // 
    // we need to save eav value, resave identity doesn't enough - we need event eav_save
    testHelper.setEavValue(primeContract, createEavAttribute, IdmIdentityContract.class, testValue, PersistentType.SHORTTEXT);
    // 
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(1, identityRoles.size());
    // 
    IdmIdentityRoleDto identityRoleDto = identityRoles.get(0);
    assertNotNull(identityRoleDto.getRoleTreeNode());
    assertEquals(automaticRole.getId(), identityRoleDto.getRoleTreeNode());
    assertEquals(automaticRole.getRole(), identityRoleDto.getRole());
    // 
    // change value and recalculate
    testHelper.setEavValue(primeContract, createEavAttribute, IdmIdentityContract.class, testValue + "-test", PersistentType.SHORTTEXT);
    // 
    // recalculate isn't needed, is done when save identity
    // 
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(0, identityRoles.size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)67 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)40 Test (org.junit.Test)40 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)32 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)22 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)15 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)15 Transactional (org.springframework.transaction.annotation.Transactional)12 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)11 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)10 ArrayList (java.util.ArrayList)9 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)7 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)7 UUID (java.util.UUID)7 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 Serializable (java.io.Serializable)5 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)4