DeleteNamedViewHandler implements OperationHandler<DeleteNamedView> { @Override public Void doOperation(final DeleteNamedView namedViewOp, final Context context, final Store store) throws OperationException { try { cache.deleteNamedView(namedViewOp.getName(), context.getUser(), store.getProperties().getAdminAuth()); } catch (final CacheOperationFailedException e) { throw new OperationException(e.getMessage(), e); } return null; } DeleteNamedViewHandler();  DeleteNamedViewHandler(final NamedViewCache cache); @Override Void doOperation(final DeleteNamedView namedViewOp, final Context context, final Store store);  }
@Test public void shouldDeleteNamedViewCorrectly() throws OperationException, CacheOperationFailedException { assertTrue(cacheContains(testNamedViewName)); final DeleteNamedView deleteNamedView = new DeleteNamedView.Builder().name(testNamedViewName).build(); deleteNamedViewHandler.doOperation(deleteNamedView, context, store); assertFalse(cacheContains(testNamedViewName)); }
@Test public void shouldNotThrowExceptionWhenNoNamedViewToDelete() throws CacheOperationFailedException, OperationException { assertTrue(cacheContains(testNamedViewName)); final DeleteNamedView deleteInvalidNamedView = new DeleteNamedView.Builder().name(invalidNamedViewName).build(); deleteNamedViewHandler.doOperation(deleteInvalidNamedView, context, store); assertTrue(cacheContains(testNamedViewName)); }