use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorController method toFilter.
private EntityEventProcessorFilter toFilter(MultiValueMap<String, Object> parameters) {
// text is filled automatically
EntityEventProcessorFilter filter = new EntityEventProcessorFilter(parameters);
filter.setDescription(getParameterConverter().toString(parameters, "description"));
filter.setEntityType(getParameterConverter().toString(parameters, "entityType"));
filter.setName(getParameterConverter().toString(parameters, "name"));
filter.setEventTypes(getParameterConverter().toStrings(parameters, "eventTypes"));
//
return filter;
}
use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testEventTypeFilter.
@Test
public void testEventTypeFilter() {
Map<String, Object> registeredProcessors = new HashMap<>();
registeredProcessors.put(IdentitySaveProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentitySaveProcessor.PROCESSOR_NAME, CoreModuleDescriptor.MODULE_ID, "description one", CoreEventType.CREATE, CoreEventType.DELETE));
registeredProcessors.put(IdentityDeleteProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentityDeleteProcessor.PROCESSOR_NAME, "custom", "description two", CoreEventType.UPDATE, CoreEventType.DELETE));
when(enabledEvaluator.isEnabled(any(Object.class))).thenReturn(true);
when(context.getBeansOfType(any())).thenReturn(registeredProcessors);
//
EntityEventProcessorFilter filter = new EntityEventProcessorFilter();
filter.setEventTypes(Lists.newArrayList("wrong"));
//
List<EntityEventProcessorDto> results = eventManager.find(filter);
Assert.assertTrue(results.isEmpty());
//
filter.setEventTypes(Lists.newArrayList(CoreEventType.DELETE.name()));
results = eventManager.find(filter);
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentitySaveProcessor.PROCESSOR_NAME)));
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentityDeleteProcessor.PROCESSOR_NAME)));
//
filter.setEventTypes(Lists.newArrayList(CoreEventType.DELETE.name(), CoreEventType.UPDATE.name()));
results = eventManager.find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentityDeleteProcessor.PROCESSOR_NAME)));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testDescriptionFilter.
@Test
public void testDescriptionFilter() {
Map<String, Object> registeredProcessors = new HashMap<>();
registeredProcessors.put(IdentitySaveProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentitySaveProcessor.PROCESSOR_NAME, CoreModuleDescriptor.MODULE_ID, "description one"));
registeredProcessors.put(IdentityDeleteProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentityDeleteProcessor.PROCESSOR_NAME, "custom", "description two"));
when(enabledEvaluator.isEnabled(any(Object.class))).thenReturn(true);
when(context.getBeansOfType(any())).thenReturn(registeredProcessors);
//
EntityEventProcessorFilter filter = new EntityEventProcessorFilter();
filter.setDescription("description");
//
List<EntityEventProcessorDto> results = eventManager.find(filter);
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentitySaveProcessor.PROCESSOR_NAME)));
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentityDeleteProcessor.PROCESSOR_NAME)));
//
filter.setDescription("one");
results = eventManager.find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentitySaveProcessor.PROCESSOR_NAME)));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testIdFilter.
@Test(expected = UnsupportedOperationException.class)
public void testIdFilter() {
Map<String, Object> registeredProcessors = new HashMap<>();
registeredProcessors.put(IdentitySaveProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentitySaveProcessor.PROCESSOR_NAME, null, null));
registeredProcessors.put(IdentityDeleteProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentityDeleteProcessor.PROCESSOR_NAME, null, null));
when(enabledEvaluator.isEnabled(any(Object.class))).thenReturn(true);
when(context.getBeansOfType(any())).thenReturn(registeredProcessors);
//
EntityEventProcessorFilter filter = new EntityEventProcessorFilter();
filter.setId(UUID.randomUUID());
eventManager.find(filter);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testEntityTypeFilter.
@Test
public void testEntityTypeFilter() {
Map<String, Object> registeredProcessors = new HashMap<>();
registeredProcessors.put(IdentitySaveProcessor.PROCESSOR_NAME, new MockIdentityProcessor(IdentitySaveProcessor.PROCESSOR_NAME, CoreModuleDescriptor.MODULE_ID, "description one", CoreEventType.CREATE, CoreEventType.DELETE));
registeredProcessors.put(IdentityDeleteProcessor.PROCESSOR_NAME, new MockRoleProcessor(IdentityDeleteProcessor.PROCESSOR_NAME, "custom", "description two", CoreEventType.UPDATE, CoreEventType.DELETE));
when(enabledEvaluator.isEnabled(any(Object.class))).thenReturn(true);
when(context.getBeansOfType(any())).thenReturn(registeredProcessors);
//
EntityEventProcessorFilter filter = new EntityEventProcessorFilter();
filter.setEntityType("wrong");
//
List<EntityEventProcessorDto> results = eventManager.find(filter);
Assert.assertTrue(results.isEmpty());
//
filter.setEntityType(IdmIdentityDto.class.getSimpleName());
results = eventManager.find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentitySaveProcessor.PROCESSOR_NAME)));
//
filter.setEntityType(IdmRoleDto.class.getSimpleName());
results = eventManager.find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentityDeleteProcessor.PROCESSOR_NAME)));
}
Aggregations