use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormDefinitionIntegrationTest method testSwitchMainDefinition.
@Test
@Transactional
public void testSwitchMainDefinition() {
String type = helper.createName();
IdmFormDefinitionDto formDefinitionOne = new IdmFormDefinitionDto();
formDefinitionOne.setType(type);
formDefinitionOne.setCode(helper.createName());
formDefinitionOne.setMain(true);
formDefinitionOne = formDefinitionService.save(formDefinitionOne);
Assert.assertTrue(formDefinitionOne.isMain());
formDefinitionOne = formDefinitionService.save(formDefinitionOne);
Assert.assertTrue(formDefinitionOne.isMain());
//
IdmFormDefinitionDto formDefinitionTwo = new IdmFormDefinitionDto();
formDefinitionTwo.setType(type);
formDefinitionTwo.setCode(helper.createName());
formDefinitionTwo.setMain(true);
formDefinitionTwo = formDefinitionService.save(formDefinitionTwo);
formDefinitionOne = formDefinitionService.get(formDefinitionOne);
//
Assert.assertFalse(formDefinitionOne.isMain());
Assert.assertTrue(formDefinitionTwo.isMain());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testMultipleValues.
/**
* Test multi values order and removal
*/
@Test
public void testMultipleValues() {
FormableEntity owner = createTestOwner("test3");
//
// create definition with multi parameter
IdmFormAttributeDto multiAttribite = new IdmFormAttributeDto();
String multiAttributeName = "name_" + System.currentTimeMillis();
multiAttribite.setCode(multiAttributeName);
multiAttribite.setName(multiAttribite.getCode());
multiAttribite.setPersistentType(PersistentType.TEXT);
multiAttribite.setMultiple(true);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), "t_v3", 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());
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1));
// 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));
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto 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.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testFindOwnersByUuidAttributeValue.
@Test
public void testFindOwnersByUuidAttributeValue() {
IdmIdentityDto owner = helper.createIdentity();
IdmIdentityDto ownerTwo = helper.createIdentity();
IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_UUID);
// save values
UUID one = UUID.randomUUID();
UUID two = UUID.randomUUID();
formService.saveValues(owner, attribute, Lists.newArrayList(one));
formService.saveValues(ownerTwo, attribute, Lists.newArrayList(two));
//
Page<? extends Identifiable> owners = formService.findOwners(owner.getClass(), InitDemoData.FORM_ATTRIBUTE_UUID, one, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(owner.getId(), owners.getContent().get(0).getId());
//
owners = formService.findOwners(owner.getClass(), InitDemoData.FORM_ATTRIBUTE_UUID, two, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(ownerTwo.getId(), owners.getContent().get(0).getId());
//
identityService.deleteById(owner.getId());
identityService.deleteById(ownerTwo.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testFindOwnersByStringAttributeValue.
@Test
public void testFindOwnersByStringAttributeValue() {
IdmIdentityDto owner = helper.createIdentity();
IdmIdentityDto ownerTwo = helper.createIdentity();
IdmIdentityDto ownerThree = helper.createIdentity();
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE);
// save values
formService.saveValues(owner.getId(), IdmIdentity.class, attribute, Lists.newArrayList(FORM_VALUE_ONE));
formService.saveValues(ownerTwo.getId(), IdmIdentity.class, attribute, Lists.newArrayList(FORM_VALUE_TWO));
formService.saveValues(ownerThree.getId(), IdmIdentity.class, attribute, Lists.newArrayList(FORM_VALUE_FOUR));
//
Page<? extends Identifiable> owners = formService.findOwners(IdmIdentity.class, attribute, FORM_VALUE_ONE, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(owner.getId(), owners.getContent().get(0).getId());
//
owners = formService.findOwners(IdmIdentity.class, attribute.getCode(), FORM_VALUE_TWO, null);
assertEquals(1, owners.getTotalElements());
//
owners = formService.findOwners(IdmIdentity.class, attribute, FORM_VALUE_FOUR, null);
assertEquals(1, owners.getTotalElements());
//
identityService.delete(owner);
identityService.delete(ownerTwo);
identityService.delete(ownerThree);
}
Aggregations