use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testContentTypeFilter.
@Test
public void testContentTypeFilter() {
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.setContentClass(IdmIdentityContractDto.class);
//
List<EntityEventProcessorDto> results = eventManager.find(filter);
Assert.assertTrue(results.isEmpty());
//
filter.setContentClass(IdmIdentityDto.class);
results = eventManager.find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentitySaveProcessor.PROCESSOR_NAME)));
//
filter.setContentClass(IdmRoleDto.class);
results = eventManager.find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(e -> e.getName().equals(IdentityDeleteProcessor.PROCESSOR_NAME)));
//
filter.setContentClass(AbstractDto.class);
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)));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testTextFilter.
@Test
public void testTextFilter() {
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.setText("wrong");
//
List<EntityEventProcessorDto> results = eventManager.find(filter);
Assert.assertTrue(results.isEmpty());
//
filter.setText("identity");
//
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)));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorFilterUnitTest method testNameFilter.
@Test
public void testNameFilter() {
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.setName(IdentitySaveProcessor.PROCESSOR_NAME);
//
List<EntityEventProcessorDto> 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 testModuleFilter.
@Test
public void testModuleFilter() {
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.setModule("wrong");
//
List<EntityEventProcessorDto> results = eventManager.find(filter);
Assert.assertTrue(results.isEmpty());
//
filter.setModule(CoreModuleDescriptor.MODULE_ID);
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 DefaultEntityEventManagerIntergationTest method testFindProcessors.
@Test
public void testFindProcessors() {
EntityEventProcessorFilter filter = null;
List<EntityEventProcessorDto> processors = entityEventManager.find(filter);
int size = processors.size();
//
assertTrue(size > 11);
//
filter = new EntityEventProcessorFilter();
filter.setContentClass(Serializable.class);
processors = entityEventManager.find(filter);
//
assertEquals(size, processors.size());
//
filter.setContentClass(TestContent.class);
processors = entityEventManager.find(filter);
//
assertEquals(11, processors.size());
}
Aggregations