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());
}
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());
}
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());
}
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());
}
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());
}
}
Aggregations