use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.
the class DefaultConfigurationService method publish.
@Override
@Transactional
public EventContext<IdmConfigurationDto> publish(EntityEvent<IdmConfigurationDto> event, EntityEvent<?> parentEvent, BasePermission... permission) {
Assert.notNull(event, "Event must be not null!");
IdmConfigurationDto content = event.getContent();
Assert.notNull(content, "Content (dto) in event must be not null!");
// load original source without confidential proxy string to support audit changes
if (!isNew(content)) {
DataFilter context = new DataFilter(getDtoClass());
context.setAddSecredProxyString(false);
event.setOriginalSource(get(content.getId(), context));
}
return super.publish(event, parentEvent, permission);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityControllerRestTest method testFindByIds.
/**
* Test search by ids - supported by default, id DataFilter is used (see #toPedicates in services - has to call super implementation)
*
* @throws Exception
*/
@Test
public void testFindByIds() {
IdmIdentityDto createdDto = createDto();
IdmIdentityDto createdDtoTwo = createDto();
// mock dto
createDto(prepareDto());
//
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
parameters.put(DataFilter.PARAMETER_ID, Lists.newArrayList(createdDto.getId().toString(), createdDtoTwo.getId().toString()));
//
List<IdmIdentityDto> results = find(parameters);
//
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDto.getId())));
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDtoTwo.getId())));
//
// find quick alias
results = findQuick(parameters);
//
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDto.getId())));
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDtoTwo.getId())));
//
results = autocomplete(parameters);
//
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDto.getId())));
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDtoTwo.getId())));
//
Assert.assertEquals(2, count(parameters));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.
the class CodeableFilterBuilderIntegrationTest method testFindIdentityByUsername.
@Test
public void testFindIdentityByUsername() {
// prepare data
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmRoleDto roleOne = getHelper().createRole();
//
DataFilter dataFilter = new DataFilter(IdmIdentityDto.class);
dataFilter.setCodeableIdentifier(identityOne.getUsername());
List<IdmIdentity> identities = identityFilter.find(dataFilter, null).getContent();
//
assertEquals(1, identities.size());
assertEquals(identityOne.getId(), identities.get(0).getId());
//
dataFilter.setCodeableIdentifier(identityTwo.getUsername());
identities = identityFilter.find(dataFilter, null).getContent();
assertEquals(1, identities.size());
assertEquals(identityTwo.getId(), identities.get(0).getId());
//
dataFilter.setCodeableIdentifier(roleOne.getId().toString());
assertEquals(0, identityFilter.find(dataFilter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.
the class CodeableFilterBuilderIntegrationTest method testFindIdentityByUuid.
@Test
public void testFindIdentityByUuid() {
// prepare data
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmRoleDto roleOne = getHelper().createRole();
//
DataFilter dataFilter = new DataFilter(IdmIdentityDto.class);
dataFilter.setCodeableIdentifier(identityOne.getId().toString());
List<IdmIdentity> identities = identityFilter.find(dataFilter, null).getContent();
//
assertEquals(1, identities.size());
assertEquals(identityOne.getId(), identities.get(0).getId());
//
dataFilter.setCodeableIdentifier(identityTwo.getId().toString());
identities = identityFilter.find(dataFilter, null).getContent();
assertEquals(1, identities.size());
assertEquals(identityTwo.getId(), identities.get(0).getId());
//
dataFilter.setCodeableIdentifier(roleOne.getId().toString());
assertEquals(0, identityFilter.find(dataFilter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.
the class DefaultFilterManagerIntegrationTest method testFilterNotSupportedWithoutValue.
@Test
public void testFilterNotSupportedWithoutValue() {
DataFilter filter = new DataFilter(IdmConfigurationDto.class);
filter.set("wrong", null);
//
Page<IdmConfigurationDto> configurations = configurationService.find(filter, PageRequest.of(0, 1));
//
Assert.assertNotNull(configurations);
}
Aggregations