### Question:
ProvisionWikiStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { if (request.getWikiSource() == null) { return; } switch (request.getWikiSource()) { case EXTENSION: sendWikiProvisioningEvent(request); extensionInstaller.installExtension(request.getWikiId(), request.getExtensionId()); sendWikiProvisionedEvent(request); break; case TEMPLATE: sendWikiProvisioningEvent(request); wikiCopier.copyDocuments(request.getTemplateId(), request.getWikiId(), false); observationManager.notify(new WikiCopiedEvent(request.getTemplateId(), request.getWikiId()), request.getTemplateId(), xcontextProvider.get()); sendWikiProvisionedEvent(request); break; default: break; } } catch (WikiManagerException | WikiCreationException e) { observationManager.notify(new WikiProvisioningFailedEvent(request.getWikiId()), request.getWikiId(), xcontextProvider.get()); throw new WikiCreationException(String.format("Failed to provision the wiki [%s].", request.getWikiId()), e); } }  @Override void execute(WikiCreationRequest request); @Override int getOrder();  }### Answer:
@Test public void executeWhenSourceIsExtension() throws Exception { WikiCreationRequest request = new WikiCreationRequest(); request.setWikiId("wikiId"); request.setWikiSource(WikiSource.EXTENSION); ExtensionId extensionId = new ExtensionId("id", "version"); request.setExtensionId(extensionId); mocker.getComponentUnderTest().execute(request); verify(extensionInstaller).installExtension(eq("wikiId"), eq(extensionId)); verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext)); verify(observationManager).notify(eq(new WikiProvisionedEvent("wikiId")), eq("wikiId"), eq(xcontext)); verifyZeroInteractions(wikiCopier); }
@Test public void executeWhenSourceIsTemplate() throws Exception { WikiCreationRequest request = new WikiCreationRequest(); request.setWikiId("wikiId"); request.setWikiSource(WikiSource.TEMPLATE); request.setTemplateId("template"); mocker.getComponentUnderTest().execute(request); verify(wikiCopier).copyDocuments(eq("template"), eq("wikiId"), eq(false)); verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext)); verify(observationManager).notify(eq(new WikiCopiedEvent("template", "wikiId")), eq("template"), eq(xcontext)); verify(observationManager).notify(eq(new WikiProvisionedEvent("wikiId")), eq("wikiId"), eq(xcontext)); verifyZeroInteractions(extensionInstaller); }
@Test public void executeWhenException() throws Exception { WikiCreationRequest request = new WikiCreationRequest(); request.setWikiId("wikiId"); request.setWikiSource(WikiSource.EXTENSION); ExtensionId extensionId = new ExtensionId("id", "version"); request.setExtensionId(extensionId); WikiCreationException exception = new WikiCreationException("Exception in ExtensionInstaller"); doThrow(exception).when(extensionInstaller).installExtension("wikiId", extensionId); WikiCreationException caughtException = null; try { mocker.getComponentUnderTest().execute(request); } catch (WikiCreationException e) { caughtException = e; } assertNotNull(caughtException); assertEquals("Failed to provision the wiki [wikiId].", caughtException.getMessage()); assertEquals(exception, caughtException.getCause()); verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext)); verify(observationManager).notify(eq(new WikiProvisioningFailedEvent("wikiId")), eq("wikiId"), eq(xcontext)); }