### Question:
OfficeServerScriptService implements ScriptService { public boolean startServer() { if (!isMainXWiki()) { setErrorMessage(ERROR_FORBIDDEN); } else if (!this.docBridge.hasProgrammingRights()) { setErrorMessage(ERROR_PRIVILEGES); } else { try { this.officeServer.start(); return true; } catch (OfficeServerException ex) { logger.error(ex.getMessage(), ex); setErrorMessage(ex.getMessage()); } } return false; }  boolean startServer(); boolean stopServer(); @Unstable boolean isConnected(); @Unstable String displayServerState(); @Deprecated String getServerState(); OfficeServerConfiguration getConfig(); String getLastErrorMessage(); static final String OFFICE_MANAGER_ERROR; }### Answer:
@Test public void startServer() throws OfficeServerException { when(this.modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki")); when(this.documentAccessBridge.hasProgrammingRights()).thenReturn(true); assertTrue(this.officeServerScriptService.startServer()); verify(this.officeServer).start(); }
@Test public void startServerForbidden() throws OfficeServerException { when(this.modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("subwiki")); when(this.documentAccessBridge.hasProgrammingRights()).thenReturn(true); assertFalse(this.officeServerScriptService.startServer()); verify(this.officeServer, never()).start(); verify(this.executionContext).setProperty(OfficeServerScriptService.OFFICE_MANAGER_ERROR, ERROR_FORBIDDEN); }
@Test public void startServerPrivileges() throws OfficeServerException { when(this.modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki")); when(this.documentAccessBridge.hasProgrammingRights()).thenReturn(false); assertFalse(this.officeServerScriptService.startServer()); verify(this.officeServer, never()).start(); verify(this.executionContext).setProperty(OfficeServerScriptService.OFFICE_MANAGER_ERROR, ERROR_PRIVILEGES); }
@Test public void startServerError() throws OfficeServerException { when(this.modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki")); when(this.documentAccessBridge.hasProgrammingRights()).thenReturn(true); doThrow(new OfficeServerException("Error while starting")).when(this.officeServer).start(); assertFalse(this.officeServerScriptService.startServer()); verify(this.officeServer).start(); verify(this.executionContext).setProperty(OfficeServerScriptService.OFFICE_MANAGER_ERROR, "Error while starting"); assertEquals("Error while starting", logCapture.getMessage(0)); }