### Question:
WikiTemplateManagerScript implements ScriptService { public boolean setTemplate(String wikiId, boolean value) { XWikiContext context = xcontextProvider.get(); try { authorizationManager.checkAccess(Right.PROGRAM, context.getDoc().getAuthorReference(), context.getDoc().getDocumentReference()); WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); String owner = descriptor.getOwnerId(); WikiReference wikiReference = new WikiReference(descriptor.getId()); String currentUser = entityReferenceSerializer.serialize(context.getUserReference()); if (!currentUser.equals(owner)) { authorizationManager.checkAccess(Right.ADMIN, context.getUserReference(), wikiReference); } wikiTemplateManager.setTemplate(wikiId, value); return true; } catch (WikiTemplateManagerException e) { error(String.format("Failed to set the template value [%s] for the wiki [%s].", value, wikiId), e); return false; } catch (AccessDeniedException e) { error(String.format("Access denied for [%s] to change the template value of the wiki [%s]. The user has" + " not the right to perform this operation or the script has not the programming right.", context.getUserReference(), wikiId), e); return false; } catch (WikiManagerException e) { error(String.format("Failed to get the descriptor of the wiki [%s].", wikiId), e); return false; } }  Exception getLastError(); Collection<WikiDescriptor> getTemplates(); boolean setTemplate(String wikiId, boolean value); Boolean isTemplate(String wikiId); @Deprecated boolean createWikiFromTemplate(String newWikiId, String newWikiAlias,
            String templateId, String ownerId, boolean failOnExist); @Deprecated Exception getLastException(); @Deprecated JobStatus getWikiProvisioningJobStatus(List<String> jobId); @Deprecated
    static final String CONTEXT_LASTEXCEPTION; }### Answer:
@Test public void setTemplateWhenCurrentUserIsOwner() throws Exception { WikiDescriptor wikiDescriptor = new WikiDescriptor("wikiId", "wikiAlias"); wikiDescriptor.setOwnerId("mainWiki:XWiki.User"); when(wikiDescriptorManager.getById("wikiId")).thenReturn(wikiDescriptor); boolean result = mocker.getComponentUnderTest().setTemplate("wikiId", true); assertTrue(result); verify(wikiTemplateManager).setTemplate("wikiId", true); result = mocker.getComponentUnderTest().setTemplate("wikiId", false); assertTrue(result); verify(wikiTemplateManager).setTemplate("wikiId", false); }