@Test public void testGetResourceId() throws Exception { PowerMockito.mockStatic(WSManUtils.class); Mockito.when(WSManUtils.isSpecificResponseAction(RESPONSE_BODY, RECEIVE_RESPONSE_ACTION)).thenReturn(true); PowerMockito.mockStatic(XMLUtils.class); Mockito.when(XMLUtils.parseXml(RESPONSE_BODY, CREATE_RESPONSE_SHELL_ID_XPATH)).thenReturn(SHELL_UUID); String result = Whitebox.invokeMethod(wsManRemoteShellServiceSpy, GET_RESOURCE_ID_METHOD, RESPONSE_BODY, RECEIVE_RESPONSE_ACTION, CREATE_RESPONSE_SHELL_ID_XPATH, SHELL_ID_NOT_RETRIEVED); assertEquals(result, SHELL_UUID); verifyStatic(); WSManUtils.isSpecificResponseAction(RESPONSE_BODY, RECEIVE_RESPONSE_ACTION); XMLUtils.parseXml(RESPONSE_BODY, CREATE_RESPONSE_SHELL_ID_XPATH); }
private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } }
WSManRemoteShellService { private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } } }
WSManRemoteShellService { private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); }
WSManRemoteShellService { private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); Map<String, String> runCommand(WSManRequestInputs wsManRequestInputs); }
WSManRemoteShellService { private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } } WSManRemoteShellService();  WSManRemoteShellService(PSEdition psEdition); Map<String, String> runCommand(WSManRequestInputs wsManRequestInputs);  }