Search in sources :

Example 56 with IdmFormDefinitionDto

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

the class DefaultFormServiceItegrationTest method testSaveValuesByOwnerId.

@Test
public void testSaveValuesByOwnerId() {
    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((UUID) owner.getId(), owner.getClass(), attribute, Lists.newArrayList(FORM_VALUE_ONE));
    assertEquals(1, attributeValues.size());
    assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
    List<IdmFormValueDto> getValues = formService.getValues((UUID) owner.getId(), owner.getClass(), attribute);
    assertEquals(1, getValues.size());
    assertEquals(FORM_VALUE_ONE, ((IdmFormValueDto) getValues.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 57 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto 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 58 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto 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 59 with IdmFormDefinitionDto

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

the class DefaultFormServiceItegrationTest method testReadDefaultDefinitionValueNotSingle.

@Test(expected = IllegalArgumentException.class)
public void testReadDefaultDefinitionValueNotSingle() {
    FormableEntity owner = createTestOwner("test5");
    try {
        IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
        // save value into default owner and default form definition
        IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW));
        value1.setValue(FORM_VALUE_ONE);
        IdmFormValueDto value2 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW));
        value2.setValue(FORM_VALUE_TWO);
        formService.saveValues(owner, formDefinition, Lists.newArrayList(value1, value2));
        IdmFormInstanceDto savedValues = formService.getFormInstance(owner);
        assertEquals(2, savedValues.getValues().size());
        savedValues.toSinglePersistentValue(InitDemoData.FORM_ATTRIBUTE_WWW);
    } finally {
        identityService.deleteById(owner.getId());
    }
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) 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 60 with IdmFormDefinitionDto

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

the class DefaultFormServiceItegrationTest method testReadDefaultDefinitionValue.

@Test
public void testReadDefaultDefinitionValue() {
    FormableEntity owner = createTestOwner("test4");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    // save value into default owner and default form definition
    IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE));
    value1.setValue(FORM_VALUE_ONE);
    formService.saveValues(owner, formDefinition, Lists.newArrayList(value1));
    IdmFormInstanceDto savedValues = formService.getFormInstance(owner);
    assertEquals(1, savedValues.getValues().size());
    assertEquals(FORM_VALUE_ONE, savedValues.toSinglePersistentValue(InitDemoData.FORM_ATTRIBUTE_PHONE));
    // 
    identityService.deleteById(owner.getId());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) 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

IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)71 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)35 Test (org.junit.Test)35 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)33 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)23 Transactional (org.springframework.transaction.annotation.Transactional)18 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)16 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)14 ApiOperation (io.swagger.annotations.ApiOperation)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)13 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)12 ArrayList (java.util.ArrayList)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 UUID (java.util.UUID)8 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)7 List (java.util.List)7 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)6 Serializable (java.io.Serializable)6