use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testMultipleValuesWithNull.
@Test
public void testMultipleValuesWithNull() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with multi parameter
IdmFormAttributeDto multiAttribite = new IdmFormAttributeDto();
String multiAttributeName = getHelper().createName();
multiAttribite.setCode(multiAttributeName);
multiAttribite.setName(multiAttribite.getCode());
multiAttribite.setPersistentType(PersistentType.TEXT);
multiAttribite.setMultiple(true);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(multiAttribite));
multiAttribite = formDefinitionOne.getMappedAttributeByCode(multiAttribite.getCode());
//
// fill values
IdmFormValueDto value1 = new IdmFormValueDto(multiAttribite);
value1.setValue(FORM_VALUE_ONE);
value1.setSeq((short) 0);
IdmFormValueDto value2 = new IdmFormValueDto(multiAttribite);
value2.setValue(FORM_VALUE_TWO);
value2.setSeq((short) 1);
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1, value2));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
// check order
assertEquals(2, m.get(multiAttributeName).size());
assertEquals(FORM_VALUE_ONE, (m.get(multiAttributeName).get(0)).getValue());
assertEquals(FORM_VALUE_TWO, (m.get(multiAttributeName).get(1)).getValue());
value2.setValue(null);
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1, value2));
// check delete unsaved multiple values
m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
assertEquals(1, m.get(multiAttributeName).size());
assertEquals(FORM_VALUE_ONE, m.get(multiAttributeName).get(0).getValue());
// checks value map
Map<String, ? extends List<Serializable>> v = formService.getFormInstance(owner, formDefinitionOne).toPersistentValueMap();
assertEquals(1, v.get(multiAttributeName).size());
assertEquals(FORM_VALUE_ONE, v.get(multiAttributeName).get(0));
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testSaveMultipleAttributeValuesToSingleAttribute.
@Test(expected = IllegalArgumentException.class)
public void testSaveMultipleAttributeValuesToSingleAttribute() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE);
// save value
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testDeleteDefinitionWithFormValues.
@Test(expected = ResultCodeException.class)
public void testDeleteDefinitionWithFormValues() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
// save password
IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PASSWORD));
value1.setValue(FORM_VALUE_ONE);
formService.saveValues(owner, formDefinition, Lists.newArrayList(value1));
List<IdmFormValueDto> savedValues = formService.getValues(owner);
assertEquals(1, savedValues.size());
formDefinitionService.delete(formDefinition);
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testDeleteSingleAttributeValues.
@Test
public void testDeleteSingleAttributeValues() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE);
IdmFormAttributeDto attributeWWW = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.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, InitDemoDataProcessor.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());
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testUnpersistedOwnerWithId.
@Test
public void testUnpersistedOwnerWithId() {
// unpersisted identity
Identifiable owner = new IdmIdentity(UUID.randomUUID());
assertTrue(formService.getValues(owner).isEmpty());
}
Aggregations