@Test public void testCropValueWithNoResultForBegin() { assertEquals("", osDetectorHelperService.cropValue("aksjd SEARCHED=expectedEND asd", "non-existent=", "END")); }
public String cropValue(String stdOut, String begin, String end) { if (containsIgnoreCase(stdOut, begin)) { return trimToEmpty(substring(stdOut, indexOfIgnoreCase(stdOut, begin) + length(begin), max(0, indexOfIgnoreCase(stdOut, end, indexOfIgnoreCase(stdOut, begin) + length(begin))))); } else { return ""; } }
OsDetectorHelperService { public String cropValue(String stdOut, String begin, String end) { if (containsIgnoreCase(stdOut, begin)) { return trimToEmpty(substring(stdOut, indexOfIgnoreCase(stdOut, begin) + length(begin), max(0, indexOfIgnoreCase(stdOut, end, indexOfIgnoreCase(stdOut, begin) + length(begin))))); } else { return ""; } } }
OsDetectorHelperService { public String cropValue(String stdOut, String begin, String end) { if (containsIgnoreCase(stdOut, begin)) { return trimToEmpty(substring(stdOut, indexOfIgnoreCase(stdOut, begin) + length(begin), max(0, indexOfIgnoreCase(stdOut, end, indexOfIgnoreCase(stdOut, begin) + length(begin))))); } else { return ""; } }  }
OsDetectorHelperService { public String cropValue(String stdOut, String begin, String end) { if (containsIgnoreCase(stdOut, begin)) { return trimToEmpty(substring(stdOut, indexOfIgnoreCase(stdOut, begin) + length(begin), max(0, indexOfIgnoreCase(stdOut, end, indexOfIgnoreCase(stdOut, begin) + length(begin))))); } else { return ""; } }  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 cropValue(String stdOut, String begin, String end) { if (containsIgnoreCase(stdOut, begin)) { return trimToEmpty(substring(stdOut, indexOfIgnoreCase(stdOut, begin) + length(begin), max(0, indexOfIgnoreCase(stdOut, end, indexOfIgnoreCase(stdOut, begin) + length(begin))))); } else { return ""; } }  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);  }