use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testSaveValuesByOwnerId.
@Test
public void testSaveValuesByOwnerId() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE);
// save value
List<IdmFormValueDto> attributeValues = formService.saveValues((UUID) owner.getId(), owner.getClass(), attribute, Lists.newArrayList(FORM_VALUE_ONE));
Assert.assertEquals(1, attributeValues.size());
Assert.assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
List<IdmFormValueDto> getValues = formService.getValues((UUID) owner.getId(), owner.getClass(), attribute);
Assert.assertEquals(1, getValues.size());
Assert.assertEquals(FORM_VALUE_ONE, ((IdmFormValueDto) getValues.get(0)).getValue());
Assert.assertEquals(FORM_VALUE_ONE, formService.getValue(owner, getValues.get(0).getId()).getValue());
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testReadDefaultDefinitionValue.
@Test
public void testReadDefaultDefinitionValue() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
// save value into default owner and default form definition
IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.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(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE));
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testChangeAttributePersistentType.
/**
* #1051 - Change value persistent type, when single attribute is saved and attribute persistent type changed
*/
@Test
public void testChangeAttributePersistentType() {
getHelper().disable(FormAttributeValidateProcessor.class);
try {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with attribute
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
String attributeName = getHelper().createName();
attribute.setCode(attributeName);
attribute.setName(attribute.getCode());
attribute.setPersistentType(PersistentType.SHORTTEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
//
// fill values
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
// check value and persistent type
assertEquals(1, m.get(attributeName).size());
assertEquals(FORM_VALUE_ONE, (m.get(attributeName).get(0)).getValue());
assertEquals(attribute.getPersistentType(), (m.get(attributeName).get(0)).getPersistentType());
//
// change attribute persistent type
attribute.setPersistentType(PersistentType.TEXT);
attribute = formService.saveAttribute(attribute);
// update value
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_TWO));
m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
// check value and persistent type
assertEquals(1, m.get(attributeName).size());
assertEquals(FORM_VALUE_TWO, (m.get(attributeName).get(0)).getValue());
assertEquals(attribute.getPersistentType(), (m.get(attributeName).get(0)).getPersistentType());
} finally {
getHelper().enable(FormAttributeValidateProcessor.class);
}
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testSaveMultipleConfidentialProperties.
@Test
public void testSaveMultipleConfidentialProperties() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with multi confidential parameter
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
String attributeName = getHelper().createName();
attribute.setCode(attributeName);
attribute.setName(attribute.getCode());
attribute.setPersistentType(PersistentType.SHORTTEXT);
attribute.setConfidential(true);
attribute.setMultiple(true);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
//
// save three values
IdmFormValueDto valueOne = new IdmFormValueDto(attribute);
valueOne.setValue(FORM_VALUE_ONE);
IdmFormValueDto valueTwo = new IdmFormValueDto(attribute);
valueTwo.setValue(FORM_VALUE_TWO);
IdmFormValueDto valueThree = new IdmFormValueDto(attribute);
valueThree.setValue(FORM_VALUE_THREE);
formService.saveValues(owner, formDefinitionOne.getId(), Lists.newArrayList(valueOne, valueTwo, valueThree));
List<IdmFormValueDto> values = formService.getValues(owner, attribute);
//
Assert.assertEquals(3, values.size());
valueOne = values.get(0);
valueTwo = values.get(1);
valueThree = values.get(2);
Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(valueOne));
Assert.assertEquals(FORM_VALUE_TWO, formService.getConfidentialPersistentValue(valueTwo));
Assert.assertEquals(FORM_VALUE_THREE, formService.getConfidentialPersistentValue(valueThree));
//
// remove value two - we need to save remaining (one, three)
valueOne.setValue(FORM_VALUE_ONE);
valueThree.setValue(FORM_VALUE_THREE);
formService.saveValues(owner, formDefinitionOne.getId(), Lists.newArrayList(valueOne, valueThree));
//
values = formService.getValues(owner, attribute);
Assert.assertEquals(2, values.size());
Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(valueOne));
Assert.assertEquals(FORM_VALUE_THREE, formService.getConfidentialPersistentValue(valueThree));
Assert.assertEquals(valueOne.getId(), values.get(0).getId());
Assert.assertEquals(valueThree.getId(), values.get(1).getId());
Assert.assertNull(formService.getConfidentialPersistentValue(valueTwo));
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testEditMultipleAttributeValues.
@Test
public void testEditMultipleAttributeValues() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
// save value
formService.saveValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
//
List<IdmFormValueDto> attributeWWWValues = formService.getValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
assertEquals(2, attributeWWWValues.size());
assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
// update
formService.saveValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_TWO));
//
attributeWWWValues = formService.getValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
assertEquals(1, attributeWWWValues.size());
assertEquals(FORM_VALUE_TWO, attributeWWWValues.get(0).getValue());
}
Aggregations