15
15
import java .nio .file .Paths ;
16
16
import java .util .Properties ;
17
17
18
+
18
19
@ Testcontainers
19
20
@ SuppressWarnings ("resource" )
20
21
public class CodeAnalyzerIntegrationTest {
@@ -165,9 +166,32 @@ void shouldBeAbleToDetectCRUDOperationsAndQueriesForPlantByWebsphere() throws Ex
165
166
"--input=/test-applications/plantsbywebsphere" ,
166
167
"--analysis-level=1" , "--verbose"
167
168
);
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" );
172
196
}
173
197
}
0 commit comments