use of org.apache.geode.management.internal.cli.converters.FilePathStringConverter in project geode by apache.
the class GfshParserConverterTest method testFilePathConverter.
@Test
public void testFilePathConverter() throws Exception {
FilePathStringConverter spy = spyConverter(FilePathStringConverter.class);
List<String> roots = Arrays.stream("/vol,/logs".split(",")).collect(Collectors.toList());
List<String> siblings = Arrays.stream("sibling1,sibling11,test1".split(",")).collect(Collectors.toList());
doReturn(roots).when(spy).getRoots();
doReturn(siblings).when(spy).getSiblings(any());
String command = "start server --properties-file=";
cursor = parser.completeAdvanced(command, candidates);
assertThat(candidates).hasSize(2);
assertThat(getCompleted(command, cursor, candidates.get(0))).isEqualTo(command + "/logs");
candidates.clear();
command = "start server --properties-file=sibling";
cursor = parser.completeAdvanced(command, candidates);
assertThat(candidates).hasSize(2);
assertThat(getCompleted(command, cursor, candidates.get(0))).isEqualTo(command + "1");
candidates.clear();
FilePathConverter spyFilePathConverter = spyConverter(FilePathConverter.class);
spyFilePathConverter.setDelegate(spy);
command = "run --file=test";
cursor = parser.completeAdvanced(command, candidates);
assertThat(candidates).hasSize(1);
assertThat(getCompleted(command, cursor, candidates.get(0))).isEqualTo(command + "1");
}
Aggregations