@SuppressWarnings("serial")
@Test
public void testCatalogFilteredGetLayers() throws Exception {
CatalogFilterAccessManager filter = new CatalogFilterAccessManager();
// make a catalog that uses our layers
Catalog withLayers = new AbstractCatalogDecorator(catalog) {
@SuppressWarnings("unchecked")
@Override
public <T extends CatalogInfo> CloseableIterator<T> list(Class<T> of, Filter filter, Integer offset, Integer count, SortBy sortBy) {
return new CloseableIteratorAdapter<T>((Iterator<T>) layers.iterator());
}
};
// and the secure catalog with the filter
SecureCatalogImpl sc = this.buildTestObject("publicRead.properties", withLayers, filter);
// base behavior sanity
assertTrue(layers.size() > 1);
assertTrue(sc.getLayers().size() > 1);
// setup a catalog filter that will hide the layer
// an example of this happening is when the LocalWorkspaceCatalogFilter
// detects 'LocalLayer.get' contains the local layer
// the result is it gets filtered out
filter.setCatalogFilters(Collections.singletonList(new AbstractCatalogFilter() {
@Override
public boolean hideLayer(LayerInfo layer) {
return layer != statesLayer;
}