@Test public void testDetectWithLocalhost() { OperatingSystemDetails detectedOs = localOsDetectorService.detectOs(new OsDetectorInputs.Builder().withHost("localhost").build()); performDetectionSuccessChecks(detectedOs); }
@Override public OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); String host = osDetectorInputs.getHost(); if (isLocalAddress(host)) { operatingSystemDetails.setName(OS_NAME); operatingSystemDetails.setVersion(OS_VERSION); operatingSystemDetails.setArchitecture(OS_ARCH); operatingSystemDetails.setFamily(osDetectorHelperService.resolveOsFamily(OS_NAME)); operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is a local address.", host))); } else { operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is not a local address.", host))); } return operatingSystemDetails; }
LocalOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); String host = osDetectorInputs.getHost(); if (isLocalAddress(host)) { operatingSystemDetails.setName(OS_NAME); operatingSystemDetails.setVersion(OS_VERSION); operatingSystemDetails.setArchitecture(OS_ARCH); operatingSystemDetails.setFamily(osDetectorHelperService.resolveOsFamily(OS_NAME)); operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is a local address.", host))); } else { operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is not a local address.", host))); } return operatingSystemDetails; } }
LocalOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); String host = osDetectorInputs.getHost(); if (isLocalAddress(host)) { operatingSystemDetails.setName(OS_NAME); operatingSystemDetails.setVersion(OS_VERSION); operatingSystemDetails.setArchitecture(OS_ARCH); operatingSystemDetails.setFamily(osDetectorHelperService.resolveOsFamily(OS_NAME)); operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is a local address.", host))); } else { operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is not a local address.", host))); } return operatingSystemDetails; } LocalOsDetectorService(OsDetectorHelperService osDetectorHelperService); }
LocalOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); String host = osDetectorInputs.getHost(); if (isLocalAddress(host)) { operatingSystemDetails.setName(OS_NAME); operatingSystemDetails.setVersion(OS_VERSION); operatingSystemDetails.setArchitecture(OS_ARCH); operatingSystemDetails.setFamily(osDetectorHelperService.resolveOsFamily(OS_NAME)); operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is a local address.", host))); } else { operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is not a local address.", host))); } return operatingSystemDetails; } LocalOsDetectorService(OsDetectorHelperService osDetectorHelperService); @Override OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs); }
LocalOsDetectorService implements OperatingSystemDetector { @Override public OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs) { OperatingSystemDetails operatingSystemDetails = new OperatingSystemDetails(); String host = osDetectorInputs.getHost(); if (isLocalAddress(host)) { operatingSystemDetails.setName(OS_NAME); operatingSystemDetails.setVersion(OS_VERSION); operatingSystemDetails.setArchitecture(OS_ARCH); operatingSystemDetails.setFamily(osDetectorHelperService.resolveOsFamily(OS_NAME)); operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is a local address.", host))); } else { operatingSystemDetails.addCommandOutput("Local", ImmutableList.of(format("%s is not a local address.", host))); } return operatingSystemDetails; } LocalOsDetectorService(OsDetectorHelperService osDetectorHelperService); @Override OperatingSystemDetails detectOs(OsDetectorInputs osDetectorInputs);  }