@Test public void testPowerShellDetection() throws SAXException, InterruptedException, TransformerException, IOException, XPathExpressionException, TimeoutException, URISyntaxException, ParserConfigurationException { doReturn(new HashMap<String, String>()).when(wsManRemoteShellService).runCommand(any(WSManRequestInputs.class)); OperatingSystemDetails toBeReturnedOsDetails = new OperatingSystemDetails(); toBeReturnedOsDetails.setArchitecture("xYZ"); toBeReturnedOsDetails.setFamily("b os fam"); toBeReturnedOsDetails.setName("b os"); toBeReturnedOsDetails.setVersion("ultimate"); doReturn(toBeReturnedOsDetails).when(osDetectorHelperService).processOutput(any(OperatingSystemDetails.class), anyMapOf(String.class, String.class), anyString()); OperatingSystemDetails actualOsDetails = powerShellOsDetectorService.detectOs(new OsDetectorInputs.Builder().withPowerShellTimeout("007").build()); assertEquals("b os", actualOsDetails.getName()); assertEquals("xYZ", actualOsDetails.getArchitecture()); assertEquals("b os fam", actualOsDetails.getFamily()); assertEquals("ultimate", actualOsDetails.getVersion()); }
@Override public OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); Map<String, String> execute = runCommandUsingPowershell(getWsManRequestInputs(wsManRequestInputs)); return osDetectorHelperService.processOutput(operatingSystemDetails, execute, POWER_SHELL); }
PowerShellOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); Map<String, String> execute = runCommandUsingPowershell(getWsManRequestInputs(wsManRequestInputs)); return osDetectorHelperService.processOutput(operatingSystemDetails, execute, POWER_SHELL); } }
PowerShellOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); Map<String, String> execute = runCommandUsingPowershell(getWsManRequestInputs(wsManRequestInputs)); return osDetectorHelperService.processOutput(operatingSystemDetails, execute, POWER_SHELL); } PowerShellOsDetectorService(OsDetectorHelperService osDetectorHelperService, WSManRemoteShellService wsManRemoteShellService); }
PowerShellOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); Map<String, String> execute = runCommandUsingPowershell(getWsManRequestInputs(wsManRequestInputs)); return osDetectorHelperService.processOutput(operatingSystemDetails, execute, POWER_SHELL); } PowerShellOsDetectorService(OsDetectorHelperService osDetectorHelperService, WSManRemoteShellService wsManRemoteShellService); @Override OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs); }
PowerShellOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); Map<String, String> execute = runCommandUsingPowershell(getWsManRequestInputs(wsManRequestInputs)); return osDetectorHelperService.processOutput(operatingSystemDetails, execute, POWER_SHELL); } PowerShellOsDetectorService(OsDetectorHelperService osDetectorHelperService, WSManRemoteShellService wsManRemoteShellService); @Override OperatingSystemDetails detectOs(OsDetectorInputs wsManRequestInputs);  }