Package org.internna.iwebmvc.model.ui

Examples of org.internna.iwebmvc.model.ui.Filter


    @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);
View Full Code Here


    @Test
    public void testGetQuery() throws Exception {
        assertEquals("SELECT e FROM Link e", impl.getQuery(Link.class, null, null).trim());
        List<Filter> filterList = new ArrayList<Filter>(2);
        assertEquals("SELECT e FROM Link e", impl.getQuery(Link.class, filterList, null).trim());
        filterList.add(new Filter());
        assertEquals("SELECT e FROM Link e", impl.getQuery(Link.class, filterList, null).trim());
        filterList.get(0).setType("TEXT");
        filterList.get(0).setPath("rel.x");
        filterList.get(0).setFrom("a");
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.rel.x) LIKE :rel_x )", impl.getQuery(Link.class, filterList, null).trim());
        filterList.get(0).setEmbedded("entity");
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.entity.rel.x) LIKE :rel_x )", impl.getQuery(Link.class, filterList, null).trim());
        filterList.get(0).setRange(true);
        filterList.get(0).setTo("b");
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.entity.rel.x) >= :rel_x ) AND ( LOWER(e.entity.rel.x) <= :rel_x_max )", impl.getQuery(Link.class, filterList, null).trim());
        filterList.get(0).setEmbedded(null);
        filterList.add(new Filter());
        filterList.get(1).setPath("whatever");
        filterList.get(1).setType("NUMBER");
        filterList.get(1).setFrom("2");
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.rel.x) >= :rel_x ) AND ( LOWER(e.rel.x) <= :rel_x_max ) AND ( e.whatever = :whatever )", impl.getQuery(Link.class, filterList, null).trim());
        filterList.get(1).setTo("3");
        filterList.get(1).setRange(true);
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.rel.x) >= :rel_x ) AND ( LOWER(e.rel.x) <= :rel_x_max ) AND ( e.whatever >= :whatever ) AND ( e.whatever <= :whatever_max )", impl.getQuery(Link.class, filterList, null).trim());
        filterList.clear();
        filterList.add(new Filter());
        filterList.get(0).setType("DATE");
        filterList.get(0).setPath("xxx");
        filterList.get(0).setFrom(String.valueOf(new Date().getTime()));
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.xxx) >= :xxx )", impl.getQuery(Link.class, filterList, null).trim());
        filterList.add(new Filter());
        filterList.get(1).setType("I18N");
        filterList.get(1).setPath("yyy");
        filterList.get(1).setFrom("a");
        filterList.get(1).setTo("a");
        filterList.get(1).setRange(true);
        assertEquals("SELECT e FROM Link e WHERE ( LOWER(e.xxx) >= :xxx ) AND ( LOWER(yyy) BETWEEN :yyy AND :yyy_max )", impl.getQuery(Link.class, filterList, null).trim());
        assertEquals("SELECT e FROM OwnedEntity e WHERE ( ( e.publicView = true ) OR ( :viewer IN ELEMENTS(e.viewers) ) )", impl.getQuery(OwnedEntity.class, null, null).trim());
        filterList.clear();
        filterList.add(new Filter());
        filterList.get(0).setType("COLLECTION");
        filterList.get(0).setPath("xxx");
        filterList.get(0).setFrom("00aa00aa00aa00aa00aa00aa00aa00aa");
        assertEquals("SELECT e FROM Link e WHERE ( :xxx IN ELEMENTS (e.xxx) )", impl.getQuery(Link.class, filterList, null).trim());
        Sort sort = new Sort();
View Full Code Here

TOP

Related Classes of org.internna.iwebmvc.model.ui.Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.