use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormDefinitionIntegrationTest method testUpdateDefinitionPersistentType.
@Test(expected = ResultCodeException.class)
@Transactional
public void testUpdateDefinitionPersistentType() {
IdmFormAttributeDto attribute = new IdmFormAttributeDto("code", "Code", PersistentType.TEXT);
IdmFormDefinitionDto formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, helper.createName(), Lists.newArrayList(attribute));
Assert.assertEquals(1, formDefinition.getFormAttributes().size());
//
// update
attribute.setPersistentType(PersistentType.DATE);
formDefinitionService.updateDefinition(IdmIdentityDto.class, formDefinition.getCode(), Lists.newArrayList(attribute));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormDefinitionIntegrationTest method testUpdateDefinition.
@Test
@Transactional
public void testUpdateDefinition() {
List<IdmFormAttributeDto> attributes = new ArrayList<>();
attributes.add(new IdmFormAttributeDto("code", "Code", PersistentType.TEXT));
attributes.add(new IdmFormAttributeDto("name", "Name", PersistentType.TEXT));
IdmFormDefinitionDto formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, helper.createName(), attributes);
// after create
Assert.assertEquals(2, formDefinition.getFormAttributes().size());
IdmFormAttributeDto code = formDefinition.getFormAttributes().get(0);
IdmFormAttributeDto name = formDefinition.getFormAttributes().get(1);
Assert.assertEquals("code", code.getCode());
Assert.assertEquals("Code", code.getName());
Assert.assertNull(code.getDescription());
Assert.assertFalse(code.isReadonly());
Assert.assertFalse(code.isRequired());
Assert.assertFalse(code.isMultiple());
Assert.assertFalse(code.isUnmodifiable());
Assert.assertNull(code.getFaceType());
Assert.assertNull(code.getPlaceholder());
Assert.assertEquals(0, code.getSeq().shortValue());
Assert.assertEquals("name", name.getCode());
Assert.assertEquals("Name", name.getName());
Assert.assertEquals(1, name.getSeq().shortValue());
// update
code.setSeq((short) 2);
code.setName("Code update");
code.setDefaultValue("default");
code.setReadonly(true);
code.setRequired(true);
code.setMultiple(true);
code.setUnmodifiable(true);
code.setPlaceholder("placeholder");
code.setDescription("description");
code.setFaceType("face");
IdmFormAttributeDto date = new IdmFormAttributeDto("date", "Date", PersistentType.DATE);
date.setSeq((short) 0);
formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, formDefinition.getCode(), Lists.newArrayList(code, name, date));
// after update
Assert.assertEquals(3, formDefinition.getFormAttributes().size());
code = formDefinition.getMappedAttributeByCode("code");
name = formDefinition.getMappedAttributeByCode("name");
date = formDefinition.getMappedAttributeByCode("date");
//
Assert.assertEquals(0, date.getSeq().shortValue());
Assert.assertEquals(1, name.getSeq().shortValue());
Assert.assertEquals(2, code.getSeq().shortValue());
//
Assert.assertEquals("code", code.getCode());
Assert.assertEquals("Code update", code.getName());
Assert.assertEquals("description", code.getDescription());
Assert.assertTrue(code.isReadonly());
Assert.assertTrue(code.isRequired());
Assert.assertTrue(code.isMultiple());
Assert.assertTrue(code.isUnmodifiable());
Assert.assertEquals("face", code.getFaceType());
Assert.assertEquals("placeholder", code.getPlaceholder());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormDefinitionIntegrationTest method testUpdateDefinitionRemoveAttribute.
@Test
@Transactional
public void testUpdateDefinitionRemoveAttribute() {
// nothing happens, it's not supported operation (filled data are lost)
IdmFormAttributeDto attributeOne = new IdmFormAttributeDto("code", "Code", PersistentType.TEXT);
IdmFormAttributeDto attributeTwo = new IdmFormAttributeDto("two", "Code", PersistentType.TEXT);
IdmFormDefinitionDto formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, helper.createName(), Lists.newArrayList(attributeOne, attributeTwo));
Assert.assertEquals(2, formDefinition.getFormAttributes().size());
//
formDefinition = formDefinitionService.updateDefinition(IdmIdentityDto.class, formDefinition.getCode(), Lists.newArrayList(attributeTwo));
Assert.assertEquals(2, formDefinition.getFormAttributes().size());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testSaveSingleAttributeValues.
@Test
public void testSaveSingleAttributeValues() {
FormableEntity owner = createTestOwner("test8");
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.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());
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testReadDefaultDefinition.
@Test
public void testReadDefaultDefinition() {
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
assertNotNull(formDefinition);
assertEquals(IdmFormDefinitionService.DEFAULT_DEFINITION_CODE, formDefinition.getCode());
assertEquals(IdmFormDefinitionService.DEFAULT_DEFINITION_CODE, formDefinition.getName());
assertEquals(PersistentType.TEXT, formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE).getPersistentType());
}
Aggregations