/**
* Tests getting filtered queries.
*/
public void testGetFilteredQueries() {
DataQuery dataQueryTest = TestUtil.getFilledDataQuery();
String dimensionName = "ga:landingPagePath";
dataQueryTest.setDimensions(dimensionName);
List<String> dimensionValues = new ArrayList<String>();
String dimensionValue = "/foo";
dimensionValues.add(dimensionValue);
// Ensure list of filters is being set.
queries = queryManager.getFilteredQueries(dataQueryTest, dimensionValues);
assertNotNull(queries);
assertNotNull(queries.getFilterList());
assertNotNull(queries.getQuery());
assertEquals(dimensionValues.size(), queries.getFilterList().size());
String expectedFilter = Filter.getEqualityFilter(dimensionName, dimensionValue);
assertEquals(expectedFilter, queries.getFilterList().get(0));
// Ensure query is updated.
DataQuery resultQuery = queries.getFilteredQuery(0);
// The following lines help setup the test. Because getFilteredQueries
// calls updateQuery, the expectedQuery is also passed through
// updateQuery.
DataQuery expectedQuery = TestUtil.getFilledDataQuery();
expectedQuery.setDimensions(dimensionName);
queryManager.updateQuery(expectedQuery);
assertEquals(expectedQuery.getMaxResults(), resultQuery.getMaxResults());
assertEquals(expectedQuery.getSort(), resultQuery.getSort());
assertEquals(expectedQuery.getDimensions(), resultQuery.getDimensions());
}