void (String typed, String[] expected, Map<String, String> macros, String completionBase, String preselected) { LocalFsFinder finder = new LocalFsFinder(false).withBaseDir(null); String input = completionBase + typed.replace("/", finder.getSeparator()); CompletionResult result = FileTextFieldUtil.processCompletion(input, finder, file -> true, new TreeMap<>(macros), null); String[] actualVariants = result.variants.stream().map(f -> FileTextFieldUtil.getLookupString(f, finder, result)).toArray(String[]::new); String[] expectedVariants = Stream.of(expected).map(s -> s.replace("/", finder.getSeparator())).toArray(String[]::new); assertThat(actualVariants).containsExactlyInAnyOrder(expectedVariants); String actualSelected = result.preselected != null ? FileTextFieldUtil.getLookupString(result.preselected, finder, result) : null; String expectedSelected = preselected != null ? preselected.replace("/", finder.getSeparator()) : null; assertThat(actualSelected).isEqualTo(expectedSelected); if (preselected != null) { assertThat(result.variants).contains(result.preselected); } }