@Test(expected = UnsupportedOperationException.class)
public void testMapFilters() throws Exception {
assertTrue(CollectionUtils.isEmpty(impl.mapFilters(null, null, null)));
List<Filter> filterList = new ArrayList<Filter>(2);
filterList.add(new Filter());
assertTrue(CollectionUtils.isEmpty(impl.mapFilters(null, filterList, null)));
filterList.get(0).setFrom("1");
assertTrue(CollectionUtils.isEmpty(impl.mapFilters(null, filterList, null)));
filterList.get(0).setPath("rel");
filterList.get(0).setType("TEXT");
Map<String, Object> filters = impl.mapFilters(null, filterList, null);
assertTrue(filters.size() == 1);
assertTrue(filters.containsKey("rel"));
assertTrue(filters.containsValue("1%"));
filterList.get(0).setType("ENUM");
filters = impl.mapFilters(Link.class, filterList, null);
assertTrue(filters.size() == 1);
assertTrue(filters.containsValue(Link.REL_TYPES.BOOKMARK));
filterList.get(0).setType("TEXT");
filterList.get(0).setTo("2");
filters = impl.mapFilters(null, filterList, null);
assertTrue(filters.size() == 2);
assertTrue(filters.containsValue("2%"));
filterList.get(0).setPath("rel.first");
filterList.get(0).setType("DATE");
Date date = new Date();
filterList.get(0).setFrom(String.valueOf(date.getTime()));
filterList.add(new Filter());
filterList.get(1).setPath("rel.none");
Double doubles = new Double("3.47");
filterList.get(1).setType("DOUBLE");
filterList.get(1).setTo(String.valueOf(doubles));
filters = impl.mapFilters(null, filterList, null);
assertTrue(filters.size() == 3);
assertTrue(filters.containsKey("rel_first"));
assertTrue(filters.containsKey("rel_none_max"));
assertTrue(filters.containsValue(date));
assertTrue(filters.containsValue(doubles));
filterList.add(new Filter());
filterList.get(2).setType("ENTITY");
filterList.get(2).setPath("readableText");
filterList.get(2).setFrom("0000aa000000aa000000aa000000aa00");
filters = impl.mapFilters(Link.class, filterList, null);
assertTrue(filters.size() == 4);
assertTrue(filters.containsValue(new UUID("0000aa000000aa000000aa000000aa00")));
userManager.setName("guest");
assertNull(impl.mapFilters(OwnedEntity.class, null, null).entrySet().iterator().next().getValue());
userManager.setName("john");
assertTrue(CollectionUtils.isNotEmpty(impl.mapFilters(OwnedEntity.class, null, new MockHttpServletRequest())));
Map<String, Object> params = impl.mapFilters(OwnedEntity.class, null, new MockHttpServletRequest());
Object o = params.entrySet().iterator().next().getValue();
assertTrue("Param is a user", o instanceof UserImpl);
filterList.clear();
filterList.add(new Filter());
filterList.get(0).setType("COLLECTION");
filterList.get(0).setPath("xxx");
filterList.get(0).setEntityClass(Link.class.getName());
filterList.get(0).setFrom(generatedID.toString());
Map<String, Object> paramsCol = impl.mapFilters(Link.class, filterList, null);