FilterQuery query = mock(FilterQuery.class);
when(query.list()).thenReturn(mockFilters);
when(query.count()).thenReturn((long) mockFilters.size());
when(query.filterId(anyString())).thenReturn(query);
when(query.singleResult()).thenReturn(mockFilters.get(0));
FilterQuery nonExistingQuery = mock(FilterQuery.class);
when(query.filterId(NON_EXISTING_ID)).thenReturn(nonExistingQuery);
when(nonExistingQuery.singleResult()).thenReturn(null);