@Test public void testExecuteCommand() throws Exception { mockExecuteRequest(); PowerMockito.mockStatic(WSManUtils.class); Mockito.when(WSManUtils.isSpecificResponseAction(RESPONSE_BODY, COMMAND_RESPONSE_ACTION)).thenReturn(true); PowerMockito.mockStatic(XMLUtils.class); Mockito.when(XMLUtils.parseXml(RESPONSE_BODY, COMMAND_RESULT_COMMAND_ID_XPATH)).thenReturn(COMMAND_UUID); String result = Whitebox.invokeMethod(new WSManRemoteShellService(), EXECUTE_COMMAND_METHOD, csHttpClientMock, httpClientInputsMock, SHELL_UUID, wsManRequestInputs, COMMAND); assertEquals(COMMAND_UUID, result); verifyStatic(); WSManUtils.isSpecificResponseAction(RESPONSE_BODY, COMMAND_RESPONSE_ACTION); XMLUtils.parseXml(RESPONSE_BODY, COMMAND_RESULT_COMMAND_ID_XPATH); }
private String executeCommand(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs, String command) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(EXECUTE_COMMAND_REQUEST_XML); documentStr = createExecuteCommandRequestBody(documentStr, httpClientInputs.getUrl(), shellId, command, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); commandExecutionStartTime = System.currentTimeMillis() / 1000; Map<String, String> executeCommandResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr); return getResourceId(executeCommandResult.get(RETURN_RESULT), COMMAND_RESPONSE_ACTION, COMMAND_RESULT_COMMAND_ID_XPATH, COMMAND_ID_NOT_RETRIEVED); }
WSManRemoteShellService { private String executeCommand(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs, String command) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(EXECUTE_COMMAND_REQUEST_XML); documentStr = createExecuteCommandRequestBody(documentStr, httpClientInputs.getUrl(), shellId, command, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); commandExecutionStartTime = System.currentTimeMillis() / 1000; Map<String, String> executeCommandResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr); return getResourceId(executeCommandResult.get(RETURN_RESULT), COMMAND_RESPONSE_ACTION, COMMAND_RESULT_COMMAND_ID_XPATH, COMMAND_ID_NOT_RETRIEVED); } }
WSManRemoteShellService { private String executeCommand(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs, String command) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(EXECUTE_COMMAND_REQUEST_XML); documentStr = createExecuteCommandRequestBody(documentStr, httpClientInputs.getUrl(), shellId, command, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); commandExecutionStartTime = System.currentTimeMillis() / 1000; Map<String, String> executeCommandResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr); return getResourceId(executeCommandResult.get(RETURN_RESULT), COMMAND_RESPONSE_ACTION, COMMAND_RESULT_COMMAND_ID_XPATH, COMMAND_ID_NOT_RETRIEVED); } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); }
WSManRemoteShellService { private String executeCommand(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs, String command) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(EXECUTE_COMMAND_REQUEST_XML); documentStr = createExecuteCommandRequestBody(documentStr, httpClientInputs.getUrl(), shellId, command, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); commandExecutionStartTime = System.currentTimeMillis() / 1000; Map<String, String> executeCommandResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr); return getResourceId(executeCommandResult.get(RETURN_RESULT), COMMAND_RESPONSE_ACTION, COMMAND_RESULT_COMMAND_ID_XPATH, COMMAND_ID_NOT_RETRIEVED); } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); Map<String, String> runCommand(WSManRequestInputs wsManRequestInputs); }
WSManRemoteShellService { private String executeCommand(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs, String command) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(EXECUTE_COMMAND_REQUEST_XML); documentStr = createExecuteCommandRequestBody(documentStr, httpClientInputs.getUrl(), shellId, command, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); commandExecutionStartTime = System.currentTimeMillis() / 1000; Map<String, String> executeCommandResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr); return getResourceId(executeCommandResult.get(RETURN_RESULT), COMMAND_RESPONSE_ACTION, COMMAND_RESULT_COMMAND_ID_XPATH, COMMAND_ID_NOT_RETRIEVED); } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); Map<String, String> runCommand(WSManRequestInputs wsManRequestInputs);  }