use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testReadDefaultDefinitionValue.
@Test
public void testReadDefaultDefinitionValue() {
FormableEntity owner = createTestOwner("test4");
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
// save value into default owner and default form definition
IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.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(InitDemoData.FORM_ATTRIBUTE_PHONE));
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testFindOwnersByMultiStringAttributeValue.
@Test
public void testFindOwnersByMultiStringAttributeValue() {
FormableEntity owner = createTestOwner("test12");
FormableEntity ownerTwo = createTestOwner("test13");
FormableEntity ownerThree = createTestOwner("test14");
IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.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());
//
identityService.deleteById(owner.getId());
identityService.deleteById(ownerTwo.getId());
identityService.deleteById(ownerThree.getId());
}
Aggregations