Search in sources :

Example 16 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testSaveMultipleAttributeValuesToSingleAttribute.

@Test(expected = IllegalArgumentException.class)
public void testSaveMultipleAttributeValuesToSingleAttribute() {
    FormableEntity owner = createTestOwner("test9");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE);
    // save value
    formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
    // 
    identityService.deleteById(owner.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 17 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity 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 18 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity 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 19 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testEditMultipleAttributeValues.

@Test
public void testEditMultipleAttributeValues() {
    FormableEntity owner = createTestOwner("test11");
    // save value
    formService.saveValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
    // 
    List<IdmFormValueDto> attributeWWWValues = formService.getValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW);
    assertEquals(2, attributeWWWValues.size());
    assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
    // update
    formService.saveValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_TWO));
    // 
    attributeWWWValues = formService.getValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW);
    assertEquals(1, attributeWWWValues.size());
    assertEquals(FORM_VALUE_TWO, attributeWWWValues.get(0).getValue());
    // 
    identityService.deleteById(owner.getId());
}
Also used : 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 20 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity 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)

Aggregations

FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)15 Test (org.junit.Test)15 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)14 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)12 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)9 Transactional (org.springframework.transaction.annotation.Transactional)6 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)5 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)4 Serializable (java.io.Serializable)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 ConfigurationClassProperty (eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 CoreEvent (eu.bcvsolutions.idm.core.api.event.CoreEvent)1