@Test( groups = {"filterbuilder"}, dataProvider = "singleQueryFilterAndOther", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleQueryFilterAndIgnoreOther(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "confirming_date IS NOT null"); Assert.assertEquals(filterCriteria.getValues().size(), 0); }
@Test( groups = {"filterbuilder"}, dataProvider = "otherQueryParams", dataProviderClass = FilterBuilderDataProvider.class) public void shouldIgnoreOtherQueryParams(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "*"); Assert.assertEquals(filterCriteria.getValues().size(), 0); }
@Test( groups = {"filterbuilder"}, dataProvider = "singleLikeFilterAndOther", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleLikeFilterAndIgnoreOther(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "text LIKE ?"); Assert.assertEquals(filterCriteria.getValues().size(), 1); Assert.assertEquals(filterCriteria.getValues().get(0), "value%"); }
@Test( groups = {"filterbuilder"}, dataProvider = "singleStartsWithFilter", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleStartsWithFilter(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "text LIKE CONCAT(?, '%')"); Assert.assertEquals(filterCriteria.getValues().size(), 1); Assert.assertEquals(filterCriteria.getValues().get(0), "value"); }
@Test( groups = {"filterbuilder"}, dataProvider = "singleOrderByFilterAndOther", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleOrderByFilterAndIgnoreOther(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "*"); Assert.assertEquals(filterCriteria.getValues().size(), 0); Assert.assertEquals(filterCriteria.getOrderBy().length, 2); }
@Test( groups = {"filterbuilder"}, dataProvider = "singleMultiQueryFilter", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleMultiQueryFilter(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals( filterCriteria.getCriteria(), "(confirming_date IS NOT null or document_count > 0)"); Assert.assertEquals(filterCriteria.getValues().size(), 0); }
@Test( groups = {"filterbuilder"}, dataProvider = "singleDateFilterAndOther", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleDateFilterAndIgnoreOther(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "date <= ? and date >= ?"); Assert.assertEquals(filterCriteria.getValues().size(), 2); Assert.assertEquals(filterCriteria.getValues().get(0), "valueTo"); Assert.assertEquals(filterCriteria.getValues().get(1), "valueFrom"); }
@Test( groups = {"filterbuilder"}, dataProvider = "singleInFilterAndOther", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildSingleInFilterAndIgnoreOther(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals(filterCriteria.getCriteria(), "id IN (?, ?, ?)"); Assert.assertEquals(filterCriteria.getValues().size(), 3); Assert.assertEquals(filterCriteria.getValues().get(0), "a"); Assert.assertEquals(filterCriteria.getValues().get(1), "b"); Assert.assertEquals(filterCriteria.getValues().get(2), "c"); }
@Test( groups = {"filterbuilder"}, dataProvider = "multiFilterAndOther", dataProviderClass = FilterBuilderDataProvider.class) public void shouldBuildMultiFilterAndIgnoreOther(Map<String, String> q) { FilterCriteria filterCriteria = filterBuilder.getFilterCriteria(q); Assert.assertEquals( filterCriteria.getCriteria(), "field2 LIKE CONCAT(?, '%') and field4 <= ? and field4 >= ? and field3 LIKE ? and field1 = ?"); Assert.assertEquals(filterCriteria.getValues().size(), 5); Assert.assertEquals(filterCriteria.getValues().get(0), "valueStw"); Assert.assertEquals(filterCriteria.getValues().get(1), "valueTo"); Assert.assertEquals(filterCriteria.getValues().get(2), "valueFrom"); Assert.assertEquals(filterCriteria.getValues().get(3), "valueLike%"); Assert.assertEquals(filterCriteria.getValues().get(4), "value"); Assert.assertEquals(filterCriteria.getOrderBy().length, 2); Assert.assertEquals(filterCriteria.getOrderBy()[0], "one asc"); Assert.assertEquals(filterCriteria.getOrderBy()[1], "two desc"); }