@Test(expected = ExecutionException.class) public final void testPerformActionWithException() throws Exception { context.checking(new Expectations() { { oneOf(tabMapper).findById(with(any(Long.class))); will(returnValue(delTab)); oneOf(tabGroupMapper).deleteTab(delTab); will(throwException(new TabDeletionException("Failed to delete tab", delTab))); } }); ServiceActionContext currentContext = new ServiceActionContext(new Long(1L), principalMock); Boolean actual = sut.execute(currentContext); assertEquals(Boolean.TRUE, actual); context.assertIsSatisfied(); }
@Override public Boolean execute(final PrincipalActionContext inActionContext) throws ExecutionException { Boolean success; try { Long tabId = (Long) inActionContext.getParams(); Tab tab = tabMapper.findById(tabId); tabGroupMapper.deleteTab(tab); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); success = true; } catch (Exception ex) { logger.error("Error occurred deleting tab.", ex); throw new ExecutionException("Error occurred deleting tab.", ex); } return success; }
DeleteTabExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final PrincipalActionContext inActionContext) throws ExecutionException { Boolean success; try { Long tabId = (Long) inActionContext.getParams(); Tab tab = tabMapper.findById(tabId); tabGroupMapper.deleteTab(tab); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); success = true; } catch (Exception ex) { logger.error("Error occurred deleting tab.", ex); throw new ExecutionException("Error occurred deleting tab.", ex); } return success; } }
DeleteTabExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final PrincipalActionContext inActionContext) throws ExecutionException { Boolean success; try { Long tabId = (Long) inActionContext.getParams(); Tab tab = tabMapper.findById(tabId); tabGroupMapper.deleteTab(tab); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); success = true; } catch (Exception ex) { logger.error("Error occurred deleting tab.", ex); throw new ExecutionException("Error occurred deleting tab.", ex); } return success; } DeleteTabExecution(final TabGroupMapper inTabGroupMapper, final TabMapper inTabMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); }
DeleteTabExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final PrincipalActionContext inActionContext) throws ExecutionException { Boolean success; try { Long tabId = (Long) inActionContext.getParams(); Tab tab = tabMapper.findById(tabId); tabGroupMapper.deleteTab(tab); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); success = true; } catch (Exception ex) { logger.error("Error occurred deleting tab.", ex); throw new ExecutionException("Error occurred deleting tab.", ex); } return success; } DeleteTabExecution(final TabGroupMapper inTabGroupMapper, final TabMapper inTabMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); @Override Boolean execute(final PrincipalActionContext inActionContext); }
DeleteTabExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final PrincipalActionContext inActionContext) throws ExecutionException { Boolean success; try { Long tabId = (Long) inActionContext.getParams(); Tab tab = tabMapper.findById(tabId); tabGroupMapper.deleteTab(tab); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); success = true; } catch (Exception ex) { logger.error("Error occurred deleting tab.", ex); throw new ExecutionException("Error occurred deleting tab.", ex); } return success; } DeleteTabExecution(final TabGroupMapper inTabGroupMapper, final TabMapper inTabMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); @Override Boolean execute(final PrincipalActionContext inActionContext);  }