1515import java .nio .file .Paths ;
1616import java .util .Properties ;
1717
18+
1819@ Testcontainers
1920@ SuppressWarnings ("resource" )
2021public class CodeAnalyzerIntegrationTest {
@@ -165,9 +166,32 @@ void shouldBeAbleToDetectCRUDOperationsAndQueriesForPlantByWebsphere() throws Ex
165166 "--input=/test-applications/plantsbywebsphere" ,
166167 "--analysis-level=1" , "--verbose"
167168 );
168- Assertions .assertTrue (runCodeAnalyzerOnPlantsByWebsphere .getStdout ().contains ("\" query_type\" : \" NAMED\" " ), "No entry point classes found" );
169- Assertions .assertTrue (runCodeAnalyzerOnPlantsByWebsphere .getStdout ().contains ("\" operation_type\" : \" READ\" " ), "No entry point methods found" );
170- Assertions .assertTrue (runCodeAnalyzerOnPlantsByWebsphere .getStdout ().contains ("\" operation_type\" : \" UPDATE\" " ), "No entry point methods found" );
171- Assertions .assertTrue (runCodeAnalyzerOnPlantsByWebsphere .getStdout ().contains ("\" operation_type\" : \" CREATE\" " ), "No entry point methods found" );
169+
170+ String output = runCodeAnalyzerOnPlantsByWebsphere .getStdout ();
171+
172+ Assertions .assertTrue (output .contains ("\" query_type\" : \" NAMED\" " ), "No entry point classes found" );
173+ Assertions .assertTrue (output .contains ("\" operation_type\" : \" READ\" " ), "No entry point methods found" );
174+ Assertions .assertTrue (output .contains ("\" operation_type\" : \" UPDATE\" " ), "No entry point methods found" );
175+ Assertions .assertTrue (output .contains ("\" operation_type\" : \" CREATE\" " ), "No entry point methods found" );
176+
177+ // Convert the expected JSON structure into a string
178+ String expectedCrudOperation =
179+ "\" crud_operations\" : [" +
180+ "{" +
181+ "\" line_number\" : 115," +
182+ "\" operation_type\" : \" READ\" ," +
183+ "\" target_table\" : null," +
184+ "\" involved_fields\" : null," +
185+ "\" condition\" : null," +
186+ "\" joined_tables\" : null," +
187+ "\" technology\" : null," +
188+ "\" is_batch_operation\" : false" +
189+ "}]" ;
190+
191+ // Remove whitespace and newlines for a more robust comparison
192+ String normalizedOutput = output .replaceAll ("\\ s+" , "" );
193+ String normalizedExpectedCrudOperation = expectedCrudOperation .replaceAll ("\\ s+" , "" );
194+
195+ Assertions .assertTrue (normalizedOutput .contains (normalizedExpectedCrudOperation ), "Expected CRUD operation JSON structure not found" );
172196 }
173197}
0 commit comments