@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); }
@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); } }
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); } } }
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); } }  }
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(); }
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();  }