Search in sources :

Example 21 with Identifiable

use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testMultipleValuesWithNull.

@Test
public void testMultipleValuesWithNull() {
    Identifiable owner = getHelper().createIdentity((GuardedString) null);
    // 
    // create definition with multi parameter
    IdmFormAttributeDto multiAttribite = new IdmFormAttributeDto();
    String multiAttributeName = getHelper().createName();
    multiAttribite.setCode(multiAttributeName);
    multiAttribite.setName(multiAttribite.getCode());
    multiAttribite.setPersistentType(PersistentType.TEXT);
    multiAttribite.setMultiple(true);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), 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());
    value2.setValue(null);
    formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1, value2));
    // 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));
}
Also used : Serializable(java.io.Serializable) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) ArrayList(java.util.ArrayList) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 22 with Identifiable

use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testSaveMultipleAttributeValuesToSingleAttribute.

@Test(expected = IllegalArgumentException.class)
public void testSaveMultipleAttributeValuesToSingleAttribute() {
    Identifiable owner = getHelper().createIdentity((GuardedString) null);
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE);
    // save value
    formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with Identifiable

use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testDeleteDefinitionWithFormValues.

@Test(expected = ResultCodeException.class)
public void testDeleteDefinitionWithFormValues() {
    Identifiable owner = getHelper().createIdentity((GuardedString) null);
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    // save password
    IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PASSWORD));
    value1.setValue(FORM_VALUE_ONE);
    formService.saveValues(owner, formDefinition, Lists.newArrayList(value1));
    List<IdmFormValueDto> savedValues = formService.getValues(owner);
    assertEquals(1, savedValues.size());
    formDefinitionService.delete(formDefinition);
}
Also used : IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with Identifiable

use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testDeleteSingleAttributeValues.

@Test
public void testDeleteSingleAttributeValues() {
    Identifiable owner = getHelper().createIdentity((GuardedString) null);
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE);
    IdmFormAttributeDto attributeWWW = formDefinition.getMappedAttributeByCode(InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
    // save value
    formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE));
    formService.saveValues(owner, attributeWWW, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
    // 
    List<IdmFormValueDto> attributeValues = formService.getValues(owner, attribute);
    assertEquals(1, attributeValues.size());
    assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
    List<IdmFormValueDto> attributeWWWValues = formService.getValues(owner, formDefinition, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
    assertEquals(2, attributeWWWValues.size());
    assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
    // 
    formService.deleteValues(owner, attribute);
    // 
    attributeValues = formService.getValues(owner, attribute);
    assertEquals(0, attributeValues.size());
    attributeWWWValues = formService.getValues(owner, attributeWWW);
    assertEquals(2, attributeWWWValues.size());
    assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 25 with Identifiable

use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testUnpersistedOwnerWithId.

@Test
public void testUnpersistedOwnerWithId() {
    // unpersisted identity
    Identifiable owner = new IdmIdentity(UUID.randomUUID());
    assertTrue(formService.getValues(owner).isEmpty());
}
Also used : IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)51 Test (org.junit.Test)37 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)32 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)31 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)27 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)24 DefaultAttachmentManagerIntegrationTest (eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest)24 List (java.util.List)19 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)17 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)16 UUID (java.util.UUID)16 ArrayList (java.util.ArrayList)14 IdmAttachmentDto (eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto)12 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Transactional (org.springframework.transaction.annotation.Transactional)11 Lists (com.google.common.collect.Lists)10 Serializable (java.io.Serializable)10 HashSet (java.util.HashSet)10 Map (java.util.Map)10 PersistentType (eu.bcvsolutions.idm.core.eav.api.domain.PersistentType)9