afedulov commented on code in PR #19660:
URL: https://github.com/apache/flink/pull/19660#discussion_r874825815


##########
flink-connectors/flink-connector-elasticsearch-base/src/test/java/org/apache/flink/connector/elasticsearch/table/IndexGeneratorTest.java:
##########
@@ -299,67 +300,58 @@ public void testGeneralDynamicIndex() {
         IndexGenerator indexGenerator =
                 IndexGeneratorFactory.createIndexGenerator("index_{item}", 
fieldNames, dataTypes);
         indexGenerator.open();
-        Assertions.assertEquals("index_apple", 
indexGenerator.generate(rows.get(0)));
-        Assertions.assertEquals("index_peanut", 
indexGenerator.generate(rows.get(1)));
+        
assertThat(indexGenerator.generate(rows.get(0))).isEqualTo("index_apple");
+        
assertThat(indexGenerator.generate(rows.get(1))).isEqualTo("index_peanut");
     }
 
     @Test
     public void testStaticIndex() {
         IndexGenerator indexGenerator =
                 IndexGeneratorFactory.createIndexGenerator("my-index", 
fieldNames, dataTypes);
         indexGenerator.open();
-        Assertions.assertEquals("my-index", 
indexGenerator.generate(rows.get(0)));
-        Assertions.assertEquals("my-index", 
indexGenerator.generate(rows.get(1)));
+        assertThat(indexGenerator.generate(rows.get(0))).isEqualTo("my-index");
+        assertThat(indexGenerator.generate(rows.get(1))).isEqualTo("my-index");
     }
 
     @Test
     public void testUnknownField() {
         String expectedExceptionMsg =
                 "Unknown field 'unknown_ts' in index pattern 
'my-index-{unknown_ts|yyyy-MM-dd}',"
                         + " please check the field name.";
-        try {
-            IndexGeneratorFactory.createIndexGenerator(
-                    "my-index-{unknown_ts|yyyy-MM-dd}", fieldNames, dataTypes);
-        } catch (TableException e) {
-            Assertions.assertEquals(e.getMessage(), expectedExceptionMsg);
-        }
+        assertThatThrownBy(
+                        () ->
+                                IndexGeneratorFactory.createIndexGenerator(
+                                        "my-index-{unknown_ts|yyyy-MM-dd}", 
fieldNames, dataTypes))
+                .isInstanceOf(TableException.class)
+                .hasMessage(expectedExceptionMsg);
     }
 
     @Test
     public void testUnsupportedTimeType() {
         String expectedExceptionMsg =
                 "Unsupported type 'INT' found in Elasticsearch dynamic index 
field, "
                         + "time-related pattern only support types are: 
DATE,TIME,TIMESTAMP.";
-        try {
-            IndexGeneratorFactory.createIndexGenerator(
-                    "my-index-{id|yyyy-MM-dd}", fieldNames, dataTypes);
-        } catch (TableException e) {
-            Assertions.assertEquals(expectedExceptionMsg, e.getMessage());
-        }
+        assertThatThrownBy(
+                        () ->
+                                IndexGeneratorFactory.createIndexGenerator(
+                                        "my-index-{id|yyyy-MM-dd}", 
fieldNames, dataTypes))
+                .isInstanceOf(TableException.class)
+                .hasMessage(expectedExceptionMsg);
     }
 
     @Test
     public void testUnsupportedMultiParametersType() {
         String expectedExceptionMsg =
                 "Chaining dynamic index pattern 
my-index-{local_date}-{local_time} is not supported,"
                         + " only support single dynamic index pattern.";
-        try {
-            IndexGeneratorFactory.createIndexGenerator(
-                    "my-index-{local_date}-{local_time}", fieldNames, 
dataTypes);
-        } catch (TableException e) {
-            Assertions.assertEquals(expectedExceptionMsg, e.getMessage());
-        }
-    }
-
-    @Test
-    public void testDynamicIndexUnsupportedFormat() {

Review Comment:
   OK, I see, so the old setup was "broken" - it was missing a fail() call on 
the "happy path".



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to