@Test public void testBuildResultFromResponseStreams() throws Exception { PowerMockito.mockStatic(WSManUtils.class); Mockito.when(WSManUtils.countStreamElements(RECEIVE_RESULT)).thenReturn(2); PowerMockito.mockStatic(XMLUtils.class); Mockito.when(XMLUtils.parseXml(anyString(), anyString())).thenReturn("c3RyZWFtX3ZhbA=="); String result = Whitebox.invokeMethod(wsManRemoteShellServiceSpy, "buildResultFromResponseStreams", RECEIVE_RESULT, OutputStream.STDOUT); assertEquals("stream_val" + "stream_val", result); verifyStatic(); WSManUtils.countStreamElements(RECEIVE_RESULT); XMLUtils.parseXml(anyString(), anyString()); }
private String buildResultFromResponseStreams(String response, OutputStream outputStream) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { StringBuilder commandResult = new StringBuilder(); int noOfStreams = WSManUtils.countStreamElements(response); for (int streamNo = 0; streamNo < noOfStreams; streamNo++) { String stream = XMLUtils.parseXml(response, String.format(RECEIVE_RESPONSE_XPATH, outputStream.getValue(), streamNo)); if (!"DQo=".equals(stream)) { commandResult.append(EncoderDecoder.decodeBase64String(stream)); } } return commandResult.toString(); }
WSManRemoteShellService { private String buildResultFromResponseStreams(String response, OutputStream outputStream) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { StringBuilder commandResult = new StringBuilder(); int noOfStreams = WSManUtils.countStreamElements(response); for (int streamNo = 0; streamNo < noOfStreams; streamNo++) { String stream = XMLUtils.parseXml(response, String.format(RECEIVE_RESPONSE_XPATH, outputStream.getValue(), streamNo)); if (!"DQo=".equals(stream)) { commandResult.append(EncoderDecoder.decodeBase64String(stream)); } } return commandResult.toString(); } }
WSManRemoteShellService { private String buildResultFromResponseStreams(String response, OutputStream outputStream) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { StringBuilder commandResult = new StringBuilder(); int noOfStreams = WSManUtils.countStreamElements(response); for (int streamNo = 0; streamNo < noOfStreams; streamNo++) { String stream = XMLUtils.parseXml(response, String.format(RECEIVE_RESPONSE_XPATH, outputStream.getValue(), streamNo)); if (!"DQo=".equals(stream)) { commandResult.append(EncoderDecoder.decodeBase64String(stream)); } } return commandResult.toString(); } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); }
WSManRemoteShellService { private String buildResultFromResponseStreams(String response, OutputStream outputStream) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { StringBuilder commandResult = new StringBuilder(); int noOfStreams = WSManUtils.countStreamElements(response); for (int streamNo = 0; streamNo < noOfStreams; streamNo++) { String stream = XMLUtils.parseXml(response, String.format(RECEIVE_RESPONSE_XPATH, outputStream.getValue(), streamNo)); if (!"DQo=".equals(stream)) { commandResult.append(EncoderDecoder.decodeBase64String(stream)); } } return commandResult.toString(); } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); Map<String, String> runCommand(WSManRequestInputs wsManRequestInputs); }
WSManRemoteShellService { private String buildResultFromResponseStreams(String response, OutputStream outputStream) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { StringBuilder commandResult = new StringBuilder(); int noOfStreams = WSManUtils.countStreamElements(response); for (int streamNo = 0; streamNo < noOfStreams; streamNo++) { String stream = XMLUtils.parseXml(response, String.format(RECEIVE_RESPONSE_XPATH, outputStream.getValue(), streamNo)); if (!"DQo=".equals(stream)) { commandResult.append(EncoderDecoder.decodeBase64String(stream)); } } return commandResult.toString(); } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); Map<String, String> runCommand(WSManRequestInputs wsManRequestInputs);  }