Package com.vaadin.data.util.filter

Examples of com.vaadin.data.util.filter.Like


    @Test
    public void getWhereStringForFilters_oneOrFilter() {
        StatementHelper sh = mockedStatementHelper("%lle", 18);
        ArrayList<Filter> filters = new ArrayList<Filter>();
        filters.add(new Or(new Like("NAME", "%lle"), new Greater("AGE", 18)));
        Assert.assertEquals(" WHERE (\"NAME\" LIKE ? OR \"AGE\" > ?)",
                QueryBuilder.getWhereStringForFilters(filters, sh));
        EasyMock.verify(sh);
    }
View Full Code Here


    @Test
    public void getWhereStringForFilters_complexCompoundFilters() {
        StatementHelper sh = mockedStatementHelper("%lle", 18, 65, "Pelle");
        ArrayList<Filter> filters = new ArrayList<Filter>();
        filters.add(new Or(new And(new Like("NAME", "%lle"), new Or(new Less(
                "AGE", 18), new Greater("AGE", 65))),
                new Equal("NAME", "Pelle")));
        Assert.assertEquals(
                " WHERE ((\"NAME\" LIKE ? AND (\"AGE\" < ? OR \"AGE\" > ?)) OR \"NAME\" = ?)",
                QueryBuilder.getWhereStringForFilters(filters, sh));
View Full Code Here

    @Test
    public void getWhereStringForFilters_complexCompoundFiltersAndSingleFilter() {
        StatementHelper sh = mockedStatementHelper("%lle", 18, 65, "Pelle",
                "Virtanen");
        ArrayList<Filter> filters = new ArrayList<Filter>();
        filters.add(new Or(new And(new Like("NAME", "%lle"), new Or(new Less(
                "AGE", 18), new Greater("AGE", 65))),
                new Equal("NAME", "Pelle")));
        filters.add(new Equal("LASTNAME", "Virtanen"));
        Assert.assertEquals(
                " WHERE ((\"NAME\" LIKE ? AND (\"AGE\" < ? OR \"AGE\" > ?)) OR \"NAME\" = ?) AND \"LASTNAME\" = ?",
View Full Code Here

    @Test
    public void setFilters_shouldReturnCorrectCount() throws SQLException {
        TableQuery tQuery = new TableQuery("people", connectionPool,
                SQLTestsConstants.sqlGen);
        List<Filter> filters = new ArrayList<Filter>();
        filters.add(new Like("NAME", "%lle"));
        tQuery.setFilters(filters);
        Assert.assertEquals(3, tQuery.getCount());
    }
View Full Code Here

        Assert.assertEquals(4, container.size());
        Assert.assertEquals("Börje",
                container.getContainerProperty(container.lastItemId(), "NAME")
                        .getValue());

        container.addContainerFilter(new Like("NAME", "%lle"));
        // Ville, Kalle, Pelle
        Assert.assertEquals(3, container.size());
        Assert.assertEquals("Pelle",
                container.getContainerProperty(container.lastItemId(), "NAME")
                        .getValue());
View Full Code Here

        Object id1 = container.addItem();
        container.getContainerProperty(id1, "NAME").setValue("Palle");
        Object id2 = container.addItem();
        container.getContainerProperty(id2, "NAME").setValue("Bengt");

        container.addContainerFilter(new Like("NAME", "%lle"));

        // Ville, Kalle, Pelle, Palle
        Assert.assertEquals(4, container.size());
        Assert.assertEquals(
                "Ville",
View Full Code Here

        Assert.assertEquals(4, container.size());
        Assert.assertEquals("Börje",
                container.getContainerProperty(container.lastItemId(), "NAME")
                        .getValue());

        container.addContainerFilter(new Like("NAME", "%lle"));
        // Ville, Kalle, Pelle
        Assert.assertEquals(3, container.size());
        Assert.assertEquals("Pelle",
                container.getContainerProperty(container.lastItemId(), "NAME")
                        .getValue());
View Full Code Here

        Object id1 = container.addItem();
        container.getContainerProperty(id1, "NAME").setValue("Palle");
        Object id2 = container.addItem();
        container.getContainerProperty(id2, "NAME").setValue("Bengt");

        container.addContainerFilter(new Like("NAME", "%lle"));

        // Ville, Kalle, Pelle, Palle
        Assert.assertEquals(4, container.size());
        Assert.assertEquals(
                "Ville",
View Full Code Here

public class LikeTest {

    @Test
    public void passesFilter_valueIsNotStringType_shouldFail() {
        Like like = new Like("test", "%foo%");

        Item item = new PropertysetItem();
        item.addItemProperty("test", new ObjectProperty<Integer>(5));

        Assert.assertFalse(like.passesFilter("id", item));
    }
View Full Code Here

        Assert.assertFalse(like.passesFilter("id", item));
    }

    @Test
    public void passesFilter_containsLikeQueryOnStringContainingValue_shouldSucceed() {
        Like like = new Like("test", "%foo%");

        Item item = new PropertysetItem();
        item.addItemProperty("test", new ObjectProperty<String>("asdfooghij"));

        Assert.assertTrue(like.passesFilter("id", item));
    }
View Full Code Here

TOP

Related Classes of com.vaadin.data.util.filter.Like

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.