use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter in project CzechIdMng by bcvsolutions.
the class IdmFormValueDtoMapperIntegrationTest method testMapWithOwner.
@Test
public void testMapWithOwner() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
//
// create definition one
IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
attributeDefinitionOne.setCode(getHelper().createName());
attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
attributeDefinitionOne.setPersistentType(PersistentType.TEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attributeDefinitionOne));
attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
//
IdmFormValueDto value = new IdmFormValueDto(attributeDefinitionOne);
value.setValue(getHelper().createName());
//
formService.saveValues(identity, formDefinitionOne, Lists.newArrayList(value));
//
IdmFormValueDto savedValue = formService.getValues(identity, formDefinitionOne).get(0);
Assert.assertEquals(value.getStringValue(), savedValue.getStringValue());
//
IdmIdentityFormValue savedEntity = identityFormValueRepository.findById(savedValue.getId()).get();
//
IdmFormValueFilter<?> context = new IdmFormValueFilter<>();
context.setAddOwnerDto(true);
IdmFormValueDto valueDto = lookupService.toDto(savedEntity, null, context);
//
Assert.assertEquals(value.getStringValue(), valueDto.getStringValue());
BaseDto owner = valueDto.getEmbedded().get(FormValueService.PROPERTY_OWNER);
Assert.assertNotNull(owner);
Assert.assertEquals(identity.getId(), owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter in project CzechIdMng by bcvsolutions.
the class IdmFormValueDtoMapperIntegrationTest method testMapWithDefaultMapper.
@Test
public void testMapWithDefaultMapper() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
//
// create definition one
IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
attributeDefinitionOne.setCode(getHelper().createName());
attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
attributeDefinitionOne.setPersistentType(PersistentType.TEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attributeDefinitionOne));
attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
//
IdmFormValueDto value = new IdmFormValueDto(attributeDefinitionOne);
value.setValue(getHelper().createName());
//
formService.saveValues(identity, formDefinitionOne, Lists.newArrayList(value));
//
IdmFormValueDto savedValue = formService.getValues(identity, formDefinitionOne).get(0);
Assert.assertEquals(value.getStringValue(), savedValue.getStringValue());
//
IdmIdentityFormValue savedEntity = identityFormValueRepository.findById(savedValue.getId()).get();
//
DefaultDtoMapper mapper = new DefaultDtoMapper(modelMapper, IdmFormValueDto.class);
IdmFormValueFilter<?> context = new IdmFormValueFilter<>();
context.setAddOwnerDto(true);
IdmFormValueDto valueDto = (IdmFormValueDto) mapper.map(savedEntity, null, context);
//
Assert.assertEquals(value.getStringValue(), valueDto.getStringValue());
BaseDto owner = valueDto.getEmbedded().get(FormValueService.PROPERTY_OWNER);
Assert.assertNull(owner);
//
valueDto = (IdmFormValueDto) mapper.map(savedEntity, new IdmFormValueDto(), null);
//
Assert.assertEquals(value.getStringValue(), valueDto.getStringValue());
owner = valueDto.getEmbedded().get(FormValueService.PROPERTY_OWNER);
Assert.assertNull(owner);
//
Assert.assertNull(mapper.map(null, null, null));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter in project CzechIdMng by bcvsolutions.
the class IdmFormValueControllerRestTest method testFindByText.
@Test
public void testFindByText() {
IdmFormValueDto valueOne = createDto();
// other
createDto();
//
IdmFormValueFilter<?> filter = new IdmFormValueFilter<>();
filter.setText(((IdmFormAttributeDto) valueOne.getEmbedded().get(IdmFormValueDto.PROPERTY_FORM_ATTRIBUTE)).getCode());
List<IdmFormValueDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(valueOne.getId())));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter in project CzechIdMng by bcvsolutions.
the class IdmFormValueControllerRestTest method testFindByDoubleValue.
@Test
public void testFindByDoubleValue() {
IdmFormValueDto value = prepareDto(PersistentType.DOUBLE);
value.setDoubleValue(BigDecimal.valueOf(1L));
IdmFormValueDto valueOne = createDto(value);
value = prepareDto(PersistentType.DOUBLE);
value.setDoubleValue(BigDecimal.valueOf(2L));
// other
createDto(value);
//
IdmFormValueFilter<?> filter = new IdmFormValueFilter<>();
filter.setDoubleValue(BigDecimal.valueOf(1L));
filter.setTransactionId(TransactionContextHolder.getContext().getTransactionId());
List<IdmFormValueDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(valueOne.getId())));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter in project CzechIdMng by bcvsolutions.
the class IdmFormValueControllerRestTest method testFindByStringValueLike.
@Test
public void testFindByStringValueLike() {
IdmFormValueDto value = prepareDto(PersistentType.TEXT);
String suffix = getHelper().createName();
value.setValue(getHelper().createName() + suffix);
IdmFormValueDto valueOne = createDto(value);
// other
createDto();
//
IdmFormValueFilter<?> filter = new IdmFormValueFilter<>();
filter.setStringValueLike(suffix);
List<IdmFormValueDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(valueOne.getId())));
}
Aggregations