@@ -71,6 +71,35 @@ void testTrapExpressionsWhichAreEscaped() {
7171 this .performStandardTestOnList (list );
7272 }
7373
74+ @ Test
75+ void testMultipleOccurrences () {
76+ List <SectionRecord > list = new LinkedList <>(Arrays .asList (
77+ new SectionRecord ("SELECT" , RandomStringUtils .randomAlphanumeric (3 , 12 )),
78+ new SectionRecord ("FROM" , RandomStringUtils .randomAlphanumeric (3 , 12 )),
79+ new SectionRecord ("JOIN" , RandomStringUtils .randomAlphanumeric (3 , 12 )),
80+ new SectionRecord ("JOIN" , RandomStringUtils .randomAlphanumeric (3 , 12 )),
81+ new SectionRecord ("JOIN" , RandomStringUtils .randomAlphanumeric (3 , 12 ))
82+ ));
83+
84+ String queryString = this .getQueryStringFromList (list );
85+ QueryStringUtil util = new QueryStringUtil (queryString );
86+
87+ SectionRecord currentRecord = list .get (0 );
88+ assertEquals (currentRecord .getValue (), util .getTopLevelSectionsByKeyword (currentRecord .getKey ()).get (0 ));
89+
90+ currentRecord = list .get (1 );
91+ assertEquals (currentRecord .getValue (), util .getTopLevelSectionsByKeyword (currentRecord .getKey ()).get (0 ));
92+
93+ currentRecord = list .get (2 );
94+ assertEquals (currentRecord .getValue (), util .getTopLevelSectionsByKeyword (currentRecord .getKey ()).get (0 ));
95+
96+ currentRecord = list .get (3 );
97+ assertEquals (currentRecord .getValue (), util .getTopLevelSectionsByKeyword (currentRecord .getKey ()).get (1 ));
98+
99+ currentRecord = list .get (4 );
100+ assertEquals (currentRecord .getValue (), util .getTopLevelSectionsByKeyword (currentRecord .getKey ()).get (2 ));
101+
102+ }
74103 /*
75104 * Boilerplate Code Reduction Methods
76105 */
0 commit comments