Service implements JSONAware { public boolean isCompliant(ResourceListQuery query) { if (query == null) { return true; } List<ResourceListFilter<?>> filters = query.getFilters(); for (ResourceListFilter<?> resourceListFilter : filters) { String filterName = resourceListFilter.getName(); Object value = resourceListFilter.getValue().get(); if (!(value instanceof String)) { return false; } String filterValue = (String) value; if (filterName.equals(ResourceListFilter.FREETEXT)) { return complies(NAME, filterValue) || complies(HOST, filterValue); } if (!complies(filterName, filterValue)) { return false; } } return true; } Service(ServiceStatistics stats); void setHost(String host); String getName(); void setName(String name); String getStatus(); void setStatus(ServiceState status); Integer getCompleted(); void setCompleted(Integer completed); Integer getRunning(); void setRunning(Integer running); Integer getQueued(); void setQueued(Integer queued); void setMeanQueueTime(long meanQueueTime); long getMeanQueueTime(); void setMeanRunTime(long meanRunTime); long getMeanRunTime(); String getHost(); @Override String toJSONString(); boolean isCompliant(ResourceListQuery query);  }
@Test public void testPositiveFreetextFilter() { ResourceListQueryImpl query = makeQuery(new StringListFilter("HOST 1")); assertTrue(service.isCompliant(query)); }
@Test public void testNegativeFreetextFilter() { ResourceListQueryImpl query = makeQuery(new StringListFilter("doesnt exist")); assertFalse(service.isCompliant(query)); }
@Test public void testConcreteFilter() { ResourceListQueryImpl query = makeQuery(new StringListFilter("host", "HOST 1")); assertTrue(service.isCompliant(query)); }
@Test public void testNegativeConcreteFilter() { ResourceListQueryImpl query = makeQuery(new StringListFilter("name", "HOST 1")); assertFalse(service.isCompliant(query)); }
@Test public void testWrongCriterion() { ResourceListQueryImpl query = makeQuery(new StringListFilter("doesntExist", "HOST 1")); assertFalse(service.isCompliant(query)); }