@Test public void execute() throws Exception { WikiCreationRequest request = new WikiCreationRequest(); request.setWikiId("wikiId"); request.setDescription("description"); request.setPrettyName("pretty name"); request.setOwnerId("ownerId"); request.setTemplate(false); request.setUserScope(UserScope.GLOBAL_ONLY); request.setMembershipType(MembershipType.INVITE); request.setWikiSource(WikiSource.EXTENSION); ExtensionId extensionId = new ExtensionId("id", "version"); request.setExtensionId(extensionId); WikiDescriptor descriptor = new WikiDescriptor("wikiId", "alias"); when(wikiDescriptorManager.getById("wikiId")).thenReturn(descriptor); mocker.getComponentUnderTest().execute(request); assertEquals("description", descriptor.getDescription()); assertEquals("pretty name", descriptor.getPrettyName()); verify(wikiDescriptorManager).saveDescriptor(descriptor); verify(wikiTemplateManager).setTemplate("wikiId", false); verify(wikiUserManager).setUserScope("wikiId", UserScope.GLOBAL_ONLY); verify(wikiUserManager).setMembershipType("wikiId", MembershipType.INVITE); }
@Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { String wikiId = request.getWikiId(); WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); descriptor.setDescription(request.getDescription()); descriptor.setPrettyName(request.getPrettyName()); wikiDescriptorManager.saveDescriptor(descriptor); wikiTemplateManager.setTemplate(wikiId, request.isTemplate()); wikiUserManager.setUserScope(wikiId, request.getUserScope()); wikiUserManager.setMembershipType(wikiId, request.getMembershipType()); } catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) { throw new WikiCreationException( String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e); } }
SaveWikiMetaDataStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { String wikiId = request.getWikiId(); WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); descriptor.setDescription(request.getDescription()); descriptor.setPrettyName(request.getPrettyName()); wikiDescriptorManager.saveDescriptor(descriptor); wikiTemplateManager.setTemplate(wikiId, request.isTemplate()); wikiUserManager.setUserScope(wikiId, request.getUserScope()); wikiUserManager.setMembershipType(wikiId, request.getMembershipType()); } catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) { throw new WikiCreationException( String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e); } } }
SaveWikiMetaDataStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { String wikiId = request.getWikiId(); WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); descriptor.setDescription(request.getDescription()); descriptor.setPrettyName(request.getPrettyName()); wikiDescriptorManager.saveDescriptor(descriptor); wikiTemplateManager.setTemplate(wikiId, request.isTemplate()); wikiUserManager.setUserScope(wikiId, request.getUserScope()); wikiUserManager.setMembershipType(wikiId, request.getMembershipType()); } catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) { throw new WikiCreationException( String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e); } }  }
SaveWikiMetaDataStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { String wikiId = request.getWikiId(); WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); descriptor.setDescription(request.getDescription()); descriptor.setPrettyName(request.getPrettyName()); wikiDescriptorManager.saveDescriptor(descriptor); wikiTemplateManager.setTemplate(wikiId, request.isTemplate()); wikiUserManager.setUserScope(wikiId, request.getUserScope()); wikiUserManager.setMembershipType(wikiId, request.getMembershipType()); } catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) { throw new WikiCreationException( String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e); } }  @Override void execute(WikiCreationRequest request); @Override int getOrder(); }
SaveWikiMetaDataStep implements WikiCreationStep { @Override public void execute(WikiCreationRequest request) throws WikiCreationException { try { String wikiId = request.getWikiId(); WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); descriptor.setDescription(request.getDescription()); descriptor.setPrettyName(request.getPrettyName()); wikiDescriptorManager.saveDescriptor(descriptor); wikiTemplateManager.setTemplate(wikiId, request.isTemplate()); wikiUserManager.setUserScope(wikiId, request.getUserScope()); wikiUserManager.setMembershipType(wikiId, request.getMembershipType()); } catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) { throw new WikiCreationException( String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e); } }  @Override void execute(WikiCreationRequest request); @Override int getOrder();  }