snuyanzin commented on code in PR #28789:
URL: https://github.com/apache/flink/pull/28789#discussion_r4178658369


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/common/sql/ConnectionITCase.java:
##########
@@ -76,11 +88,87 @@ void testCreateTemporaryConnectionRejectsDuplicate() {
 
     @Test
     void testCreatePermanentConnectionRejectedWithoutSecretStore() {
-        assertThatThrownBy(() -> tEnv().executeSql("CREATE CONNECTION my_conn 
WITH ('k' = 'v')"))
+        assertThatThrownBy(() -> tEnv.executeSql("CREATE CONNECTION my_conn 
WITH ('k' = 'v')"))
                 .isInstanceOf(ValidationException.class)
                 .hasMessageContaining("WritableSecretStore must be 
configured");
     }
 
+    @Test
+    void testDropTemporaryConnection() {
+        tEnv.executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' = 
'v')");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isPresent();
+
+        tEnv.executeSql("DROP TEMPORARY CONNECTION my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropTemporaryConnectionIfExists() {
+        tEnv.executeSql("DROP TEMPORARY CONNECTION IF EXISTS my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropMissingTemporaryConnectionRejected() {
+        assertThatThrownBy(() -> tEnv.executeSql("DROP TEMPORARY CONNECTION 
my_conn"))
+                .isInstanceOf(ValidationException.class)
+                .hasMessage(
+                        "Temporary connection with identifier '%s' does not 
exist.",
+                        connectionIdentifier("my_conn").asSummaryString());
+    }
+
+    @Test
+    void testDropPermanentConnection() throws Exception {
+        ObjectIdentifier identifier = connectionIdentifier("my_conn");
+        catalogManager()
+                .getCatalog(identifier.getCatalogName())
+                .orElseThrow()
+                .createConnection(
+                        identifier.toObjectPath(),
+                        CatalogConnection.of(Map.of("k", "v"), null),
+                        false);
+        assertThat(catalogManager().getConnection(identifier)).isPresent();
+
+        tEnv.executeSql("DROP CONNECTION my_conn");
+
+        assertThat(catalogManager().getConnection(identifier)).isEmpty();
+    }
+
+    @Test
+    void testDropPermanentConnectionIfExists() {
+        tEnv.executeSql("DROP CONNECTION IF EXISTS my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropMissingPermanentConnectionRejected() {
+        assertThatThrownBy(() -> tEnv.executeSql("DROP CONNECTION my_conn"))
+                .isInstanceOf(ValidationException.class)
+                .hasMessage(
+                        "Connection with identifier '%s' does not exist.",
+                        connectionIdentifier("my_conn").asSummaryString());
+    }
+
+    @Test
+    void testDropTemporarySystemConnectionRejected() {
+        tEnv.executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' = 
'v')");
+
+        for (String statement :
+                List.of(
+                        "DROP TEMPORARY SYSTEM CONNECTION my_conn",
+                        "DROP TEMPORARY SYSTEM CONNECTION IF EXISTS my_conn",
+                        "DROP TEMPORARY SYSTEM CONNECTION IF EXISTS 
missing_conn")) {
+            assertThatThrownBy(() -> tEnv.executeSql(statement))
+                    .isInstanceOf(ValidationException.class)
+                    .hasMessageContaining("DROP TEMPORARY SYSTEM CONNECTION is 
not supported");

Review Comment:
   what is this?
   AI slop trying to combine parameterized tests inside a regular one?
   
   please be aware that if you use AI it is expected the PR is scrutinized by 
original author first before asking for human review



-- 
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