Search in sources :

Example 6 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testUnpersistedOwnerWithId.

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

Example 7 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testFindOwnersByDateAttributeValue.

@Test
public void testFindOwnersByDateAttributeValue() {
    FormableEntity owner = createTestOwner("test15");
    FormableEntity ownerTwo = createTestOwner("test16");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_DATETIME);
    // save values
    DateTime now = new DateTime();
    DateTime tomorrow = now.plusDays(1);
    formService.saveValues(owner, attribute, Lists.newArrayList(now));
    formService.saveValues(ownerTwo, attribute, Lists.newArrayList(tomorrow));
    // 
    Page<? extends Identifiable> owners = formService.findOwners(owner.getClass(), InitDemoData.FORM_ATTRIBUTE_DATETIME, now, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(owner.getId(), owners.getContent().get(0).getId());
    // 
    owners = formService.findOwners(owner.getClass(), InitDemoData.FORM_ATTRIBUTE_DATETIME, tomorrow, null);
    // 
    assertEquals(1, owners.getTotalElements());
    assertEquals(ownerTwo.getId(), owners.getContent().get(0).getId());
    // 
    identityService.deleteById(owner.getId());
    identityService.deleteById(ownerTwo.getId());
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) DateTime(org.joda.time.DateTime) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testDeleteDefinitionWithFormValues.

@Test(expected = ResultCodeException.class)
public void testDeleteDefinitionWithFormValues() {
    FormableEntity owner = createTestOwner("test7");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    // save password
    IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.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);
    // 
    identityService.deleteById(owner.getId());
}
Also used : IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testDeleteSingleAttributeValues.

@Test
public void testDeleteSingleAttributeValues() {
    FormableEntity owner = createTestOwner("test10");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE);
    IdmFormAttributeDto attributeWWW = formDefinition.getMappedAttributeByCode(InitDemoData.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, InitDemoData.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());
    // 
    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) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with FormableEntity

use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testReadConfidentialFormValue.

@Test
public void testReadConfidentialFormValue() {
    FormableEntity owner = createTestOwner("test6");
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    // save password
    IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PASSWORD));
    value1.setValue(FORM_VALUE_ONE);
    formService.saveValues(owner, formDefinition, Lists.newArrayList(value1));
    IdmFormInstanceDto savedValues = formService.getFormInstance(owner);
    assertEquals(1, savedValues.getValues().size());
    assertEquals(GuardedString.SECRED_PROXY_STRING, savedValues.toSinglePersistentValue(InitDemoData.FORM_ATTRIBUTE_PASSWORD));
    // 
    identityService.deleteById(owner.getId());
}
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) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)15 Test (org.junit.Test)15 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)14 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)12 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)9 Transactional (org.springframework.transaction.annotation.Transactional)6 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)5 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)4 Serializable (java.io.Serializable)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 ConfigurationClassProperty (eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 CoreEvent (eu.bcvsolutions.idm.core.api.event.CoreEvent)1