PakhomovAlexander commented on code in PR #1502:
URL: https://github.com/apache/ignite-3/pull/1502#discussion_r1071011567


##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given

Review Comment:
   // Given files



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given
+
+        // Create temp folder
+        File folder = Files.newTemporaryFolder();
+
+        // Create temp files
+        String script1 = folder.getPath() + File.separator + "script1.sql";
+        Files.newFile(script1).deleteOnExit();
+
+        String script2 = folder.getPath() + File.separator + "script2.sql";
+        Files.newFile(script2).deleteOnExit();
+
+        String someFile = folder.getPath() + File.separator + "someFile.sql";
+        Files.newFile(someFile).deleteOnExit();
+
+        // Then
+
+        // Search in the folder
+        List<String> completions1 = complete(words("sql", "--script-file", 
folder.getPath()));
+        // Contains all files
+        assertThat(completions1, contains(script1, script2, someFile));
+
+        // Search in the folder for files which starts with 'scrpit'
+        List<String> completions2 = complete(words("sql", "--script-file", 
folder.getPath() + File.separator + "script"));
+        // Contains script1 and script2 files
+        assertThat(completions2, contains(script1, script2));

Review Comment:
   // Then ...



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given
+
+        // Create temp folder
+        File folder = Files.newTemporaryFolder();
+
+        // Create temp files
+        String script1 = folder.getPath() + File.separator + "script1.sql";
+        Files.newFile(script1).deleteOnExit();
+
+        String script2 = folder.getPath() + File.separator + "script2.sql";
+        Files.newFile(script2).deleteOnExit();
+
+        String someFile = folder.getPath() + File.separator + "someFile.sql";
+        Files.newFile(someFile).deleteOnExit();
+
+        // Then
+
+        // Search in the folder
+        List<String> completions1 = complete(words("sql", "--script-file", 
folder.getPath()));
+        // Contains all files
+        assertThat(completions1, contains(script1, script2, someFile));

Review Comment:
   // Then completions contain all given files



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+

Review Comment:
   looks like this empty line is not needed.



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")

Review Comment:
   Could you please add the test case for the folder that contains only folders 
but not files? Would it be completed correctly?



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given
+
+        // Create temp folder
+        File folder = Files.newTemporaryFolder();
+
+        // Create temp files
+        String script1 = folder.getPath() + File.separator + "script1.sql";
+        Files.newFile(script1).deleteOnExit();
+
+        String script2 = folder.getPath() + File.separator + "script2.sql";
+        Files.newFile(script2).deleteOnExit();
+
+        String someFile = folder.getPath() + File.separator + "someFile.sql";
+        Files.newFile(someFile).deleteOnExit();
+
+        // Then
+
+        // Search in the folder
+        List<String> completions1 = complete(words("sql", "--script-file", 
folder.getPath()));
+        // Contains all files
+        assertThat(completions1, contains(script1, script2, someFile));
+
+        // Search in the folder for files which starts with 'scrpit'
+        List<String> completions2 = complete(words("sql", "--script-file", 
folder.getPath() + File.separator + "script"));

Review Comment:
   // When complete --script-file with partial path to script



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), 
containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, 
containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", 
""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", 
""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = 
nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given
+
+        // Create temp folder
+        File folder = Files.newTemporaryFolder();
+
+        // Create temp files
+        String script1 = folder.getPath() + File.separator + "script1.sql";
+        Files.newFile(script1).deleteOnExit();
+
+        String script2 = folder.getPath() + File.separator + "script2.sql";
+        Files.newFile(script2).deleteOnExit();
+
+        String someFile = folder.getPath() + File.separator + "someFile.sql";
+        Files.newFile(someFile).deleteOnExit();
+
+        // Then

Review Comment:
   // When complete --script-file with folder typed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to