use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.
the class ServiceTest method testNegativeFreetextFilter.
@Test
public void testNegativeFreetextFilter() {
ResourceListQueryImpl query = makeQuery(new StringListFilter("doesnt exist"));
assertFalse(service.isCompliant(query));
}
use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.
the class ServiceTest method testNegativeConcreteFilter.
@Test
public void testNegativeConcreteFilter() {
ResourceListQueryImpl query = makeQuery(new StringListFilter("name", "HOST 1"));
assertFalse(service.isCompliant(query));
}
use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.
the class ListProvidersServiceTest method testQuery.
@Test
public void testQuery() throws ListProviderException {
ResourceListQueryImpl query = new ResourceListQueryImpl();
final String providerName1 = "test1";
final Map<String, String> list1 = new HashMap<String, String>();
list1.put("1", "x test34");
list1.put("2", "a test12");
list1.put("3", "c ok");
list1.put("4", "z essai test");
listProviderService.addProvider(getResourceListProvider(providerName1, list1));
query.setLimit(2);
query.setOffset(1);
Assert.assertEquals(2, listProviderService.getList(providerName1, query, null, false).size());
query.setLimit(1);
query.setOffset(5);
Assert.assertEquals(0, listProviderService.getList(providerName1, query, null, false).size());
query.setLimit(2);
query.setOffset(1);
Assert.assertEquals(2, listProviderService.getList(providerName1, query, null, false).size());
query.setLimit(12);
query.setOffset(0);
query.addFilter(new StringListFilter(TEST_FILTER_NAME, "test"));
Assert.assertEquals(3, listProviderService.getList(providerName1, query, null, false).size());
// query.setSortedBy(TEST_SORTBY);
// Map<String, String> list = listProviderService.getList(providerName1, query, null);
// int i = 0;
// Iterator<Entry<String, String>> iterator = list.entrySet().iterator();
// Assert.assertEquals(list1.get("2"), iterator.next().getValue());
}
use of org.opencastproject.index.service.resources.list.query.StringListFilter in project opencast by opencast.
the class EndpointUtil method addRequestFiltersToQuery.
/**
* Add the string based filters to the given list query.
*
* @param filterString
* The string based filters
* @param query
* The query to update with the filters
*/
public static void addRequestFiltersToQuery(final String filterString, ResourceListQueryImpl query) {
if (filterString != null) {
String[] filters = filterString.split(",");
for (String filter : filters) {
String[] splitFilter = filter.split(":", 2);
if (splitFilter != null && splitFilter.length == 2) {
String key = splitFilter[0].trim();
String value = splitFilter[1].trim();
query.addFilter(new StringListFilter(key, value));
}
}
}
}
Aggregations