use of org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl 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.ResourceListQueryImpl 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.ResourceListQueryImpl 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.ResourceListQueryImpl in project opencast by opencast.
the class ListProvidersServiceTest method testAddandRemove.
@Test
public void testAddandRemove() throws ListProviderException {
final String providerName1 = "test1";
final Map<String, String> list1 = new HashMap<String, String>();
list1.put("1", "test");
list1.put("2", "test");
list1.put("3", "test");
list1.put("4", "test");
final String providerName2 = "test2";
final Map<String, String> list2 = new HashMap<String, String>();
list2.put("1", "test");
list2.put("2", "test");
list2.put("3", "test");
list2.put("4", "test");
int baseNumber = listProviderService.getAvailableProviders().size();
ResourceListQuery query = new ResourceListQueryImpl();
listProviderService.addProvider(getResourceListProvider(providerName1, list1));
listProviderService.addProvider(getResourceListProvider(providerName2, list2));
Assert.assertEquals(baseNumber + 2, listProviderService.getAvailableProviders().size());
Assert.assertTrue(listProviderService.hasProvider(providerName1));
Assert.assertTrue(listProviderService.hasProvider(providerName2));
Assert.assertEquals(list1, listProviderService.getList(providerName1, query, null, false));
Assert.assertEquals(list2, listProviderService.getList(providerName2, query, null, false));
listProviderService.removeProvider(providerName2);
Assert.assertEquals(baseNumber + 1, listProviderService.getAvailableProviders().size());
Assert.assertFalse(listProviderService.hasProvider(providerName2));
}
use of org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl in project opencast by opencast.
the class ListProvidersEndpoint method getComponents.
@GET
@Path("components.json")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "components", description = "Provides a set of constants lists (right now only eventCommentReasons) for use in the admin UI", reponses = { @RestResponse(description = "Returns a set of constants lists (right now only eventCommentReasons) for use in the admin UI", responseCode = HttpServletResponse.SC_OK) }, returnDescription = "")
public Response getComponents(@Context HttpHeaders headers) {
String[] sources = { "eventCommentReasons" };
ResourceListQuery query = new ResourceListQueryImpl();
JSONObject list = new JSONObject();
for (String source : sources) {
if (listProvidersService.hasProvider(source)) {
JSONObject subList;
try {
subList = generateJSONObject(listProvidersService.getList(source, query, securityService.getOrganization(), true));
list.put(source, subList);
} catch (JsonCreationException e) {
logger.error("Not able to generate resources list JSON from source {}: {}", source, e);
return SERVER_ERROR;
} catch (ListProviderException e) {
logger.error("Not able to get list from provider {}: {}", source, e);
return SERVER_ERROR;
}
} else {
return NOT_FOUND;
}
}
return Response.ok(list.toString()).build();
}
Aggregations