Search in sources :

Example 26 with IdmFormAttributeDto

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

the class DefaultFormDefinitionIntegrationTest method testUpdateDefinitionRemoveAttribute.

@Test
@Transactional
public void testUpdateDefinitionRemoveAttribute() {
    // nothing happens, it's not supported operation (filled data are lost)
    IdmFormAttributeDto attributeOne = new IdmFormAttributeDto("code", "Code", PersistentType.TEXT);
    IdmFormAttributeDto attributeTwo = new IdmFormAttributeDto("two", "Code", PersistentType.TEXT);
    IdmFormDefinitionDto formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, helper.createName(), Lists.newArrayList(attributeOne, attributeTwo));
    Assert.assertEquals(2, formDefinition.getFormAttributes().size());
    // 
    formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, formDefinition.getCode(), Lists.newArrayList(attributeTwo));
    Assert.assertEquals(2, formDefinition.getFormAttributes().size());
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testSaveSingleAttributeValues.

@Test
public void testSaveSingleAttributeValues() {
    FormableEntity owner = createTestOwner("test8");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE);
    // save value
    List<IdmFormValueDto> attributeValues = formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE));
    assertEquals(1, attributeValues.size());
    assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
    attributeValues = formService.getValues(owner, attribute);
    assertEquals(1, attributeValues.size());
    assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
    // 
    identityService.deleteById(owner.getId());
}
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) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 28 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testFindAttributeNotExist.

@Test
public void testFindAttributeNotExist() {
    IdmFormAttributeDto attribute = formService.getAttribute(IdmIdentity.class, "notExist_test");
    // 
    assertNull(attribute);
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testFindOwnersByDateAttributeValue.

@Test
public void testFindOwnersByDateAttributeValue() {
    FormableEntity owner = createTestOwner("test15");
    FormableEntity ownerTwo = createTestOwner("test16");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_DATETIME);
    // save values
    DateTime now = new DateTime();
    DateTime tomorrow = now.plusDays(1);
    formService.saveValues(owner, attribute, Lists.newArrayList(now));
    formService.saveValues(ownerTwo, attribute, Lists.newArrayList(tomorrow));
    // 
    Page<? extends Identifiable> owners = formService.findOwners(owner.getClass(), InitDemoData.FORM_ATTRIBUTE_DATETIME, now, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(owner.getId(), owners.getContent().get(0).getId());
    // 
    owners = formService.findOwners(owner.getClass(), InitDemoData.FORM_ATTRIBUTE_DATETIME, tomorrow, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(ownerTwo.getId(), owners.getContent().get(0).getId());
    // 
    identityService.deleteById(owner.getId());
    identityService.deleteById(ownerTwo.getId());
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) DateTime(org.joda.time.DateTime) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with IdmFormAttributeDto

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

the class DefaultFormServiceItegrationTest method testDeleteSingleAttributeValues.

@Test
public void testDeleteSingleAttributeValues() {
    FormableEntity owner = createTestOwner("test10");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE);
    IdmFormAttributeDto attributeWWW = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW);
    // save value
    formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE));
    formService.saveValues(owner, attributeWWW, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
    // 
    List<IdmFormValueDto> attributeValues = formService.getValues(owner, attribute);
    assertEquals(1, attributeValues.size());
    assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
    List<IdmFormValueDto> attributeWWWValues = formService.getValues(owner, formDefinition, InitDemoData.FORM_ATTRIBUTE_WWW);
    assertEquals(2, attributeWWWValues.size());
    assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
    // 
    formService.deleteValues(owner, attribute);
    // 
    attributeValues = formService.getValues(owner, attribute);
    assertEquals(0, attributeValues.size());
    attributeWWWValues = formService.getValues(owner, attributeWWW);
    assertEquals(2, attributeWWWValues.size());
    assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
    // 
    identityService.deleteById(owner.getId());
}
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) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) 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