use of eu.bcvsolutions.idm.core.api.dto.filter.FilterBuilderFilter in project CzechIdMng by bcvsolutions.
the class FilterBuilderControllerRestTest method testEnable.
@Test
public void testEnable() throws Exception {
try {
getHelper().enableFilter(defaultManagersFilter.getClass());
//
FilterBuilderFilter filter = new FilterBuilderFilter();
filter.setFilterBuilderClass(AutowireHelper.getTargetType(defaultManagersFilter));
List<FilterBuilderDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(defaultManagersFilter.getName(), results.get(0).getName());
Assert.assertEquals(defaultManagersFilter.getEntityClass(), results.get(0).getEntityClass());
Assert.assertFalse(results.get(0).isDisabled());
//
filter.setFilterBuilderClass(AutowireHelper.getTargetType(guaranteeManagersFilter));
results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertEquals(guaranteeManagersFilter.getName(), results.get(0).getName());
Assert.assertEquals(guaranteeManagersFilter.getEntityClass(), results.get(0).getEntityClass());
Assert.assertTrue(results.get(0).isDisabled());
//
getMockMvc().perform(put(BaseController.BASE_PATH + "/filter-builders/" + results.get(0).getId() + "/enable").with(authentication(getAdminAuthentication())).contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().is2xxSuccessful());
//
filter.setFilterBuilderClass(AutowireHelper.getTargetType(defaultManagersFilter));
results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertEquals(defaultManagersFilter.getName(), results.get(0).getName());
Assert.assertEquals(defaultManagersFilter.getEntityClass(), results.get(0).getEntityClass());
Assert.assertTrue(results.get(0).isDisabled());
//
filter.setFilterBuilderClass(AutowireHelper.getTargetType(guaranteeManagersFilter));
results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertEquals(guaranteeManagersFilter.getName(), results.get(0).getName());
Assert.assertEquals(guaranteeManagersFilter.getEntityClass(), results.get(0).getEntityClass());
Assert.assertFalse(results.get(0).isDisabled());
} finally {
getHelper().enableFilter(defaultManagersFilter.getClass());
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.FilterBuilderFilter in project CzechIdMng by bcvsolutions.
the class DefaultFilterManagerUnitTest method testFindByFilterBuilderClass.
@Test
@SuppressWarnings("serial")
public void testFindByFilterBuilderClass() {
FilterBuilderDto dto = new FilterBuilderDto();
dto.setModule("test");
dto.setEntityClass(IdmIdentity.class);
dto.setFilterBuilderClass(IdmIdentityService.class);
//
FilterBuilderFilter filter = new FilterBuilderFilter();
filter.setFilterBuilderClass(IdmIdentityService.class.getCanonicalName());
Assert.assertTrue(manager.passFilter(dto, filter));
filter.setFilterBuilderClass(IdmIdentityService.class.getSimpleName());
Assert.assertFalse(manager.passFilter(dto, filter));
// inline classes with null cannonical name
dto.setFilterBuilderClass((new IdmIdentity() {
}).getClass());
filter.setFilterBuilderClass(IdmIdentity.class.getCanonicalName());
Assert.assertFalse(manager.passFilter(dto, filter));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.FilterBuilderFilter in project CzechIdMng by bcvsolutions.
the class DefaultFilterManagerUnitTest method testEmptyFilter.
@Test
public void testEmptyFilter() {
Assert.assertTrue(manager.passFilter(new FilterBuilderDto(), null));
FilterBuilderFilter filter = new FilterBuilderFilter();
Assert.assertTrue(manager.passFilter(new FilterBuilderDto(), filter));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.FilterBuilderFilter in project CzechIdMng by bcvsolutions.
the class FilterBuilderControllerRestTest method testFindByName.
@Test
public void testFindByName() {
FilterBuilderFilter filter = new FilterBuilderFilter();
filter.setName(defaultManagersFilter.getName());
filter.setEntityClass(IdmIdentity.class.getCanonicalName());
List<FilterBuilderDto> results = find(filter);
//
Assert.assertFalse(results.isEmpty());
Assert.assertTrue(results.stream().anyMatch(f -> f.getFilterBuilderClass().equals(AutowireHelper.getTargetClass(defaultManagersFilter))));
Assert.assertTrue(results.stream().anyMatch(f -> f.getFilterBuilderClass().equals(AutowireHelper.getTargetClass(guaranteeManagersFilter))));
Assert.assertTrue(results.stream().allMatch(f -> f.getEntityClass().equals(IdmIdentity.class)));
Assert.assertTrue(results.stream().allMatch(f -> f.getName().equals(defaultManagersFilter.getName())));
//
// not-exists
filter.setName(getHelper().createName());
filter.setEntityClass(IdmIdentity.class.getCanonicalName());
results = find(filter);
Assert.assertTrue(results.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.FilterBuilderFilter in project CzechIdMng by bcvsolutions.
the class DefaultFilterManagerUnitTest method testFindByDescription.
@Test
public void testFindByDescription() {
FilterBuilderDto dto = new FilterBuilderDto();
dto.setDescription("tesT-x");
dto.setEntityClass(IdmIdentity.class);
//
FilterBuilderFilter filter = new FilterBuilderFilter();
filter.setDescription("Test-x");
Assert.assertTrue(manager.passFilter(dto, filter));
filter.setDescription("test-");
Assert.assertTrue(manager.passFilter(dto, filter));
filter.setDescription("tee");
Assert.assertFalse(manager.passFilter(dto, filter));
dto.setDescription(null);
Assert.assertFalse(manager.passFilter(dto, filter));
}
Aggregations