@Test public void executeWhenException() throws Exception { WikiCreationRequest request = new WikiCreationRequest(); request.setWikiId("wikiId"); request.setAlias("wikiAlias"); request.setOwnerId("owner"); request.setFailOnExist(true); Exception exception = new WikiManagerException("Exception in WikiManager."); doThrow(exception).when(wikiManager).create(any(), any(), any(), anyBoolean()); WikiCreationException caughtException = null; try { mocker.getComponentUnderTest().execute(request); } catch (WikiCreationException e) { caughtException = e; } assertNotNull(caughtException); assertEquals("Failed to create the wiki [wikiId].", caughtException.getMessage()); assertEquals(exception, caughtException.getCause()); }
@Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { wikiManager.create(request.getWikiId(), request.getAlias(), request.getOwnerId(), request.isFailOnExist()); } catch (WikiManagerException e) { throw new WikiCreationException(String.format("Failed to create the wiki [%s].", request.getWikiId()), e); } }
CreateWikiStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { wikiManager.create(request.getWikiId(), request.getAlias(), request.getOwnerId(), request.isFailOnExist()); } catch (WikiManagerException e) { throw new WikiCreationException(String.format("Failed to create the wiki [%s].", request.getWikiId()), e); } } }
CreateWikiStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { wikiManager.create(request.getWikiId(), request.getAlias(), request.getOwnerId(), request.isFailOnExist()); } catch (WikiManagerException e) { throw new WikiCreationException(String.format("Failed to create the wiki [%s].", request.getWikiId()), e); } }  }
CreateWikiStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { wikiManager.create(request.getWikiId(), request.getAlias(), request.getOwnerId(), request.isFailOnExist()); } catch (WikiManagerException e) { throw new WikiCreationException(String.format("Failed to create the wiki [%s].", request.getWikiId()), e); } }  @Override void execute(WikiCreationRequest request); @Override int getOrder(); }
CreateWikiStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { wikiManager.create(request.getWikiId(), request.getAlias(), request.getOwnerId(), request.isFailOnExist()); } catch (WikiManagerException e) { throw new WikiCreationException(String.format("Failed to create the wiki [%s].", request.getWikiId()), e); } }  @Override void execute(WikiCreationRequest request); @Override int getOrder();  }