use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testFindOwnersByMultiStringAttributeValue.
@Test
public void testFindOwnersByMultiStringAttributeValue() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
Identifiable ownerTwo = getHelper().createIdentity((GuardedString) null);
Identifiable ownerThree = getHelper().createIdentity((GuardedString) null);
IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
// save values
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
formService.saveValues(ownerTwo, attribute, Lists.newArrayList(FORM_VALUE_THREE, FORM_VALUE_TWO));
formService.saveValues(ownerThree, attribute, Lists.newArrayList(FORM_VALUE_FOUR, FORM_VALUE_FOUR));
//
Page<? extends Identifiable> owners = formService.findOwners(owner.getClass(), attribute, FORM_VALUE_ONE, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(owner.getId(), owners.getContent().get(0).getId());
//
owners = formService.findOwners(owner.getClass(), attribute.getCode(), FORM_VALUE_TWO, null);
assertEquals(2, owners.getTotalElements());
//
owners = formService.findOwners(owner.getClass(), attribute, FORM_VALUE_FOUR, null);
assertEquals(1, owners.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testUpdateConfidentialProperty.
@Test
public void testUpdateConfidentialProperty() {
Identifiable owner = getHelper().createIdentity((GuardedString) null);
//
// create definition with confidential parameter
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
String attributeName = getHelper().createName();
attribute.setCode(attributeName);
attribute.setName(attribute.getCode());
attribute.setPersistentType(PersistentType.SHORTTEXT);
attribute.setConfidential(true);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
//
// fill values
IdmFormValueDto value1 = new IdmFormValueDto(attribute);
value1.setValue(FORM_VALUE_ONE);
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
// check
Assert.assertEquals(1, m.get(attributeName).size());
Assert.assertEquals(GuardedString.SECRED_PROXY_STRING, (m.get(attributeName).get(0)).getValue());
Assert.assertTrue(m.get(attributeName).get(0).isConfidential());
//
// check confidential value
Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(m.get(attributeName).get(0)));
//
// save other values - confidential will not be included
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList());
Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(m.get(attributeName).get(0)));
//
// update
IdmFormValueDto confidentialValue = m.get(attributeName).get(0);
confidentialValue.setValue("");
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(confidentialValue));
Assert.assertEquals("", formService.getConfidentialPersistentValue(m.get(attributeName).get(0)));
//
// update 2
confidentialValue = m.get(attributeName).get(0);
confidentialValue.setValue(FORM_VALUE_ONE);
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(confidentialValue));
Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(m.get(attributeName).get(0)));
//
confidentialValue.setValue(null);
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(confidentialValue));
Assert.assertNull(formService.getConfidentialPersistentValue(m.get(attributeName).get(0)));
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testReadDefaultDefinitionValueNotSingle.
@Test(expected = IllegalArgumentException.class)
public void testReadDefaultDefinitionValueNotSingle() {
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_WWW));
value1.setValue(FORM_VALUE_ONE);
IdmFormValueDto value2 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.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(InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testDeleteEmptyValue.
@Test
public void testDeleteEmptyValue() {
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());
// update value
// empty string
formService.saveValues(owner, attribute, Lists.newArrayList(""));
m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
//
assertEquals(1, m.get(attributeName).size());
assertEquals("", (m.get(attributeName).get(0)).getValue());
assertEquals(attribute.getPersistentType(), (m.get(attributeName).get(0)).getPersistentType());
}
use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testSaveSingleAttributeValues.
@Test
public void testSaveSingleAttributeValues() {
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(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE));
assertEquals(1, attributeValues.size());
assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
attributeValues = formService.getValues(owner, attribute);
assertEquals(1, attributeValues.size());
assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
}
Aggregations