@Test public void testResolveOsFamily() { assertEquals("Other", osDetectorHelperService.resolveOsFamily("dummy")); assertEquals("Linux", osDetectorHelperService.resolveOsFamily("linux")); assertEquals("Linux", osDetectorHelperService.resolveOsFamily("Linux")); assertEquals("Windows", osDetectorHelperService.resolveOsFamily("windows")); assertEquals("Windows", osDetectorHelperService.resolveOsFamily("windOWS")); assertEquals("SunOS", osDetectorHelperService.resolveOsFamily("soLAris")); assertEquals("FreeBSD", osDetectorHelperService.resolveOsFamily("freebsd")); }
public String resolveOsFamily(String osName) { if (isEmpty(osName)) { return ""; } Map<String, String> osFamilyResolverMap = new HashMap<String, String>() {{ put("windows", "Windows"); put("microsoft", "Windows"); put("linux", "Linux"); put("ubuntu", "Linux"); put("red hat", "Linux"); put("redhat", "Linux"); put("rhel", "Linux"); put("debian", "Linux"); put("suse", "Linux"); put("android", "Linux"); put("centos", "Linux"); put("fedora", "Linux"); put("gentoo", "Linux"); put("ultrasparc", "Linux"); put("ultra sparc", "Linux"); put("darwin", "Darwin"); put("mac", "Darwin"); put("os x", "Darwin"); put("sunos", "SunOS"); put("solaris", "SunOS"); put("openindiana", "SunOS"); put("open indiana", "SunOS"); put("smartos", "SunOS"); put("smart os", "SunOS"); put("omnios", "SunOS"); put("omni os", "SunOS"); put("dragonfly", "DragonFly"); put("dragon fly", "DragonFly"); put("freebsd", "FreeBSD"); put("free bsd", "FreeBSD"); put("hp-ux", "HP-UX"); }}; for (Map.Entry<String, String> osFamilyResolver : osFamilyResolverMap.entrySet()) { if (containsIgnoreCase(osName, osFamilyResolver.getKey())) { return osFamilyResolver.getValue(); } } return "Other"; }
OsDetectorHelperService { public String resolveOsFamily(String osName) { if (isEmpty(osName)) { return ""; } Map<String, String> osFamilyResolverMap = new HashMap<String, String>() {{ put("windows", "Windows"); put("microsoft", "Windows"); put("linux", "Linux"); put("ubuntu", "Linux"); put("red hat", "Linux"); put("redhat", "Linux"); put("rhel", "Linux"); put("debian", "Linux"); put("suse", "Linux"); put("android", "Linux"); put("centos", "Linux"); put("fedora", "Linux"); put("gentoo", "Linux"); put("ultrasparc", "Linux"); put("ultra sparc", "Linux"); put("darwin", "Darwin"); put("mac", "Darwin"); put("os x", "Darwin"); put("sunos", "SunOS"); put("solaris", "SunOS"); put("openindiana", "SunOS"); put("open indiana", "SunOS"); put("smartos", "SunOS"); put("smart os", "SunOS"); put("omnios", "SunOS"); put("omni os", "SunOS"); put("dragonfly", "DragonFly"); put("dragon fly", "DragonFly"); put("freebsd", "FreeBSD"); put("free bsd", "FreeBSD"); put("hp-ux", "HP-UX"); }}; for (Map.Entry<String, String> osFamilyResolver : osFamilyResolverMap.entrySet()) { if (containsIgnoreCase(osName, osFamilyResolver.getKey())) { return osFamilyResolver.getValue(); } } return "Other"; } }
OsDetectorHelperService { public String resolveOsFamily(String osName) { if (isEmpty(osName)) { return ""; } Map<String, String> osFamilyResolverMap = new HashMap<String, String>() {{ put("windows", "Windows"); put("microsoft", "Windows"); put("linux", "Linux"); put("ubuntu", "Linux"); put("red hat", "Linux"); put("redhat", "Linux"); put("rhel", "Linux"); put("debian", "Linux"); put("suse", "Linux"); put("android", "Linux"); put("centos", "Linux"); put("fedora", "Linux"); put("gentoo", "Linux"); put("ultrasparc", "Linux"); put("ultra sparc", "Linux"); put("darwin", "Darwin"); put("mac", "Darwin"); put("os x", "Darwin"); put("sunos", "SunOS"); put("solaris", "SunOS"); put("openindiana", "SunOS"); put("open indiana", "SunOS"); put("smartos", "SunOS"); put("smart os", "SunOS"); put("omnios", "SunOS"); put("omni os", "SunOS"); put("dragonfly", "DragonFly"); put("dragon fly", "DragonFly"); put("freebsd", "FreeBSD"); put("free bsd", "FreeBSD"); put("hp-ux", "HP-UX"); }}; for (Map.Entry<String, String> osFamilyResolver : osFamilyResolverMap.entrySet()) { if (containsIgnoreCase(osName, osFamilyResolver.getKey())) { return osFamilyResolver.getValue(); } } return "Other"; }  }
OsDetectorHelperService { public String resolveOsFamily(String osName) { if (isEmpty(osName)) { return ""; } Map<String, String> osFamilyResolverMap = new HashMap<String, String>() {{ put("windows", "Windows"); put("microsoft", "Windows"); put("linux", "Linux"); put("ubuntu", "Linux"); put("red hat", "Linux"); put("redhat", "Linux"); put("rhel", "Linux"); put("debian", "Linux"); put("suse", "Linux"); put("android", "Linux"); put("centos", "Linux"); put("fedora", "Linux"); put("gentoo", "Linux"); put("ultrasparc", "Linux"); put("ultra sparc", "Linux"); put("darwin", "Darwin"); put("mac", "Darwin"); put("os x", "Darwin"); put("sunos", "SunOS"); put("solaris", "SunOS"); put("openindiana", "SunOS"); put("open indiana", "SunOS"); put("smartos", "SunOS"); put("smart os", "SunOS"); put("omnios", "SunOS"); put("omni os", "SunOS"); put("dragonfly", "DragonFly"); put("dragon fly", "DragonFly"); put("freebsd", "FreeBSD"); put("free bsd", "FreeBSD"); put("hp-ux", "HP-UX"); }}; for (Map.Entry<String, String> osFamilyResolver : osFamilyResolverMap.entrySet()) { if (containsIgnoreCase(osName, osFamilyResolver.getKey())) { return osFamilyResolver.getValue(); } } return "Other"; }  String formatOsCommandsOutput(Map<String, List<String>> commandsOutput); void validateNmapInputs(OsDetectorInputs osDetectorInputs, NmapOsDetectorService nmapOsDetectorService); String cropValue(String stdOut, String begin, String end); boolean foundOperatingSystem(OperatingSystemDetails os); OperatingSystemDetails processOutput(OperatingSystemDetails operatingSystemDetails, Map<String, String> execute, String detectOption); String resolveOsFamily(String osName); }
OsDetectorHelperService { public String resolveOsFamily(String osName) { if (isEmpty(osName)) { return ""; } Map<String, String> osFamilyResolverMap = new HashMap<String, String>() {{ put("windows", "Windows"); put("microsoft", "Windows"); put("linux", "Linux"); put("ubuntu", "Linux"); put("red hat", "Linux"); put("redhat", "Linux"); put("rhel", "Linux"); put("debian", "Linux"); put("suse", "Linux"); put("android", "Linux"); put("centos", "Linux"); put("fedora", "Linux"); put("gentoo", "Linux"); put("ultrasparc", "Linux"); put("ultra sparc", "Linux"); put("darwin", "Darwin"); put("mac", "Darwin"); put("os x", "Darwin"); put("sunos", "SunOS"); put("solaris", "SunOS"); put("openindiana", "SunOS"); put("open indiana", "SunOS"); put("smartos", "SunOS"); put("smart os", "SunOS"); put("omnios", "SunOS"); put("omni os", "SunOS"); put("dragonfly", "DragonFly"); put("dragon fly", "DragonFly"); put("freebsd", "FreeBSD"); put("free bsd", "FreeBSD"); put("hp-ux", "HP-UX"); }}; for (Map.Entry<String, String> osFamilyResolver : osFamilyResolverMap.entrySet()) { if (containsIgnoreCase(osName, osFamilyResolver.getKey())) { return osFamilyResolver.getValue(); } } return "Other"; }  String formatOsCommandsOutput(Map<String, List<String>> commandsOutput); void validateNmapInputs(OsDetectorInputs osDetectorInputs, NmapOsDetectorService nmapOsDetectorService); String cropValue(String stdOut, String begin, String end); boolean foundOperatingSystem(OperatingSystemDetails os); OperatingSystemDetails processOutput(OperatingSystemDetails operatingSystemDetails, Map<String, String> execute, String detectOption); String resolveOsFamily(String osName);  }