@@ -75,7 +75,9 @@ public class TeragrepSyntaxTests {
7575 "teragrep_hdfs_save_all_params" ,
7676 "teragrep_hdfs_save_codec" ,
7777 "teragrep_syslog_stream" ,
78- "teragrep_syslog_stream_host_port"
78+ "teragrep_syslog_stream_host_port" ,
79+ "teragrep_foreachbatch" ,
80+ "teragrep_foreachbatch_transformStatement"
7981 })
8082 public void teragrepSyntaxParseTest (String arg ) {
8183 String fileName = "src/test/resources/antlr4/commands/teragrep/" + arg + ".txt" ;
@@ -393,4 +395,36 @@ void testRegexExtractWithParams(String arg) {
393395 assertEquals (1 , inputNodes .getLength ());
394396 assertEquals (1 , outputNodes .getLength ());
395397 }
398+
399+ @ ParameterizedTest
400+ @ ValueSource (strings = {
401+ "teragrep_foreachbatch" ,
402+ })
403+ void testTeragrepForEachBatch (String arg ) {
404+ ParserStructureTestingUtility pstu = new ParserStructureTestingUtility ();
405+ String fileName = "src/test/resources/antlr4/commands/teragrep/" + arg + ".txt" ;
406+
407+ String febParamPath = "/root/transformStatement/teragrepTransformation/t_execParameter/t_forEachBatchParameter" ;
408+ NodeList febParamNodes = Assertions .assertDoesNotThrow (() -> (NodeList ) pstu .xpathQueryFile (fileName , febParamPath , false ));
409+
410+ // Check that 1 found for each path
411+ assertEquals (1 , febParamNodes .getLength ());
412+ }
413+
414+ @ ParameterizedTest
415+ @ ValueSource (strings = {
416+ "teragrep_foreachbatch_transformStatement" ,
417+ })
418+ void testTeragrepForEachBatchWithTransformStatement (String arg ) {
419+ ParserStructureTestingUtility pstu = new ParserStructureTestingUtility ();
420+ String fileName = "src/test/resources/antlr4/commands/teragrep/" + arg + ".txt" ;
421+
422+ String febParamPath = "/root/transformStatement/teragrepTransformation/t_execParameter/t_forEachBatchParameter" ;
423+ String transformStmtPath = "/root/transformStatement/transformStatement/statsTransformation" ;
424+ NodeList febParamNodes = Assertions .assertDoesNotThrow (() -> (NodeList ) pstu .xpathQueryFile (fileName , febParamPath , false ));
425+ NodeList transformStmtNodes = Assertions .assertDoesNotThrow (() -> (NodeList ) pstu .xpathQueryFile (fileName , transformStmtPath , false ));
426+
427+ assertEquals (1 , febParamNodes .getLength ());
428+ assertEquals (1 , transformStmtNodes .getLength ());
429+ }
396430}
0 commit comments