Search in sources :

Example 1 with FilePathStringConverter

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");
}
Also used : FilePathStringConverter(org.apache.geode.management.internal.cli.converters.FilePathStringConverter) FilePathConverter(org.apache.geode.management.internal.cli.converters.FilePathConverter) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

FilePathConverter (org.apache.geode.management.internal.cli.converters.FilePathConverter)1 FilePathStringConverter (org.apache.geode.management.internal.cli.converters.FilePathStringConverter)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1