Search in sources :

Example 16 with Identifiable

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

the class DefaultFormServiceIntegrationTest method testSaveValuesByOwnerId.

@Test
public void testSaveValuesByOwnerId() {
    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((UUID) owner.getId(), owner.getClass(), attribute, Lists.newArrayList(FORM_VALUE_ONE));
    Assert.assertEquals(1, attributeValues.size());
    Assert.assertEquals(FORM_VALUE_ONE, attributeValues.get(0).getValue());
    List<IdmFormValueDto> getValues = formService.getValues((UUID) owner.getId(), owner.getClass(), attribute);
    Assert.assertEquals(1, getValues.size());
    Assert.assertEquals(FORM_VALUE_ONE, ((IdmFormValueDto) getValues.get(0)).getValue());
    Assert.assertEquals(FORM_VALUE_ONE, formService.getValue(owner, getValues.get(0).getId()).getValue());
    // 
    identityService.deleteById(owner.getId());
}
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 17 with Identifiable

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

the class DefaultFormServiceIntegrationTest method testReadDefaultDefinitionValue.

@Test
public void testReadDefaultDefinitionValue() {
    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_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(InitDemoDataProcessor.FORM_ATTRIBUTE_PHONE));
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) 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 18 with Identifiable

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

the class DefaultFormServiceIntegrationTest method testChangeAttributePersistentType.

/**
 * #1051 - Change value persistent type, when single attribute is saved and attribute persistent type changed
 */
@Test
public void testChangeAttributePersistentType() {
    getHelper().disable(FormAttributeValidateProcessor.class);
    try {
        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());
        // 
        // change attribute persistent type
        attribute.setPersistentType(PersistentType.TEXT);
        attribute = formService.saveAttribute(attribute);
        // update value
        formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_TWO));
        m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
        // 
        // check value and persistent type
        assertEquals(1, m.get(attributeName).size());
        assertEquals(FORM_VALUE_TWO, (m.get(attributeName).get(0)).getValue());
        assertEquals(attribute.getPersistentType(), (m.get(attributeName).get(0)).getPersistentType());
    } finally {
        getHelper().enable(FormAttributeValidateProcessor.class);
    }
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) 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 19 with Identifiable

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

the class DefaultFormServiceIntegrationTest method testSaveMultipleConfidentialProperties.

@Test
public void testSaveMultipleConfidentialProperties() {
    Identifiable owner = getHelper().createIdentity((GuardedString) null);
    // 
    // create definition with multi confidential parameter
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    String attributeName = getHelper().createName();
    attribute.setCode(attributeName);
    attribute.setName(attribute.getCode());
    attribute.setPersistentType(PersistentType.SHORTTEXT);
    attribute.setConfidential(true);
    attribute.setMultiple(true);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
    attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
    // 
    // save three values
    IdmFormValueDto valueOne = new IdmFormValueDto(attribute);
    valueOne.setValue(FORM_VALUE_ONE);
    IdmFormValueDto valueTwo = new IdmFormValueDto(attribute);
    valueTwo.setValue(FORM_VALUE_TWO);
    IdmFormValueDto valueThree = new IdmFormValueDto(attribute);
    valueThree.setValue(FORM_VALUE_THREE);
    formService.saveValues(owner, formDefinitionOne.getId(), Lists.newArrayList(valueOne, valueTwo, valueThree));
    List<IdmFormValueDto> values = formService.getValues(owner, attribute);
    // 
    Assert.assertEquals(3, values.size());
    valueOne = values.get(0);
    valueTwo = values.get(1);
    valueThree = values.get(2);
    Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(valueOne));
    Assert.assertEquals(FORM_VALUE_TWO, formService.getConfidentialPersistentValue(valueTwo));
    Assert.assertEquals(FORM_VALUE_THREE, formService.getConfidentialPersistentValue(valueThree));
    // 
    // remove value two - we need to save remaining (one, three)
    valueOne.setValue(FORM_VALUE_ONE);
    valueThree.setValue(FORM_VALUE_THREE);
    formService.saveValues(owner, formDefinitionOne.getId(), Lists.newArrayList(valueOne, valueThree));
    // 
    values = formService.getValues(owner, attribute);
    Assert.assertEquals(2, values.size());
    Assert.assertEquals(FORM_VALUE_ONE, formService.getConfidentialPersistentValue(valueOne));
    Assert.assertEquals(FORM_VALUE_THREE, formService.getConfidentialPersistentValue(valueThree));
    Assert.assertEquals(valueOne.getId(), values.get(0).getId());
    Assert.assertEquals(valueThree.getId(), values.get(1).getId());
    Assert.assertNull(formService.getConfidentialPersistentValue(valueTwo));
}
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) 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 20 with Identifiable

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

the class DefaultFormServiceIntegrationTest method testEditMultipleAttributeValues.

@Test
public void testEditMultipleAttributeValues() {
    Identifiable owner = getHelper().createIdentity((GuardedString) null);
    // save value
    formService.saveValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
    // 
    List<IdmFormValueDto> attributeWWWValues = formService.getValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
    assertEquals(2, attributeWWWValues.size());
    assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
    // update
    formService.saveValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_TWO));
    // 
    attributeWWWValues = formService.getValues(owner, InitDemoDataProcessor.FORM_ATTRIBUTE_WWW);
    assertEquals(1, attributeWWWValues.size());
    assertEquals(FORM_VALUE_TWO, attributeWWWValues.get(0).getValue());
}
Also used : 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)

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