GetAllNamedViewsHandler implements OutputOperationHandler<GetAllNamedViews, CloseableIterable<NamedViewDetail>> { @Override public CloseableIterable<NamedViewDetail> doOperation(final GetAllNamedViews operation, final Context context, final Store store) throws OperationException { try { return cache.getAllNamedViews(context.getUser()); } catch (final CacheOperationFailedException e) { throw new OperationException(e.getMessage(), e); } } GetAllNamedViewsHandler();  GetAllNamedViewsHandler(final NamedViewCache cache); @Override CloseableIterable<NamedViewDetail> doOperation(final GetAllNamedViews operation, final Context context, final Store store);  }
@Test public void shouldGetAllAccessibleNamedViewsFromCache() throws OperationException { initialiseCache(); final NamedViewDetail namedViewAsDetail = new NamedViewDetail.Builder() .name(testNamedViewName) .view(view) .creatorId(context.getUser().getUserId()) .build(); addNamedViewHandler.doOperation(addNamedView, context, store); final NamedViewDetail namedViewAsDetail2 = new NamedViewDetail.Builder() .name(testNamedViewName + 2) .view(view2) .creatorId(context.getUser().getUserId()) .build(); addNamedViewHandler.doOperation(addNamedView2, context, store); addNamedViewHandler.doOperation(addNamedViewWithNoAccess, context, store); final GetAllNamedViews getAllNamedViews = new GetAllNamedViews.Builder().build(); GetAllNamedViewsHandler getAllNamedViewsHandler = new GetAllNamedViewsHandler(namedViewCache); CloseableIterable<NamedViewDetail> namedViewList = getAllNamedViewsHandler.doOperation(getAllNamedViews, context, store); assertEquals(2, Iterables.size(namedViewList)); assertTrue(Iterables.contains(namedViewList, namedViewAsDetail)); assertTrue(Iterables.contains(namedViewList, namedViewAsDetail2)); }