1010import api .messages .params .AnalyzeParams ;
1111import com .google .gson .Gson ;
1212import com .google .gson .reflect .TypeToken ;
13- import com .ibm .wala .util .collections .Pair ;
1413import com .ibm .wala .classLoader .Module ;
14+ import com .ibm .wala .util .collections .Pair ;
1515import goblintserver .GoblintConfWatcher ;
1616import goblintserver .GoblintServer ;
1717import gobpie .GobPieConfiguration ;
@@ -161,9 +161,15 @@ public void testConvertMessagesFromJson() throws IOException {
161161 verify (analysisConsumer ).consume (response , "GobPie" );
162162 }
163163
164+ /**
165+ * Mock test to ensure that the Goblint warnings with Explode received from a response in JSON format
166+ * are correctly converted to {@link AnalysisResult} objects
167+ * and passed to {@link MagpieServer} via {@link AnalysisConsumer}.
168+ *
169+ * @throws IOException when reading messagesResponse.json from resources fails.
170+ */
164171 @ Test
165172 public void testConvertMessagesFromJsonWithExplode () throws IOException {
166- /**
167173 List <GoblintMessagesResult > goblintMessagesResults = readGoblintResponseJson ();
168174 when (goblintService .messages ()).thenReturn (CompletableFuture .completedFuture (goblintMessagesResults ));
169175 when (gobPieConfiguration .showCfg ()).thenReturn (false );
@@ -188,22 +194,32 @@ public void testConvertMessagesFromJsonWithExplode() throws IOException {
188194 );
189195 response .add (
190196 new GoblintMessagesAnalysisResult (
191- new GoblintPosition(4, 4, 4, 12, exampleUrl),
192- "[Race] Memory location myglobal (race with conf. 110)",
197+ new GoblintPosition (10 , 10 , 2 , 21 , exampleUrl ),
198+ "[Race] Group: Memory location myglobal (race with conf. 110)\n " +
199+ "write with [mhp:{tid=[main, t_fun@src/example.c:17:3-17:40#top]}, lock:{mutex1}, thread:[main, t_fun@src/example.c:17:3-17:40#top]] (conf. 110) (exp: & myglobal)" ,
193200 "Warning" ,
194- List.of(
195- Pair.make(
196- new GoblintPosition(10, 10, 2, 21, exampleUrl),
197- " write with [mhp:{tid=[main, t_fun@src/example.c:17:3-17:40#top]}, lock:{mutex1}, thread:[main, t_fun@src/example.c:17:3-17:40#top]] (conf. 110) (exp: & myglobal)"
198- ),
199- Pair.make(
201+ List .of (Pair .make (
200202 new GoblintPosition (19 , 19 , 2 , 21 , exampleUrl ),
201203 "write with [mhp:{tid=[main]; created={[main, t_fun@src/example.c:17:3-17:40#top]}}, lock:{mutex2}, thread:[main]] (conf. 110) (exp: & myglobal)"
202204 )
203205 )
204206 )
205207
206208 );
209+ response .add (
210+ new GoblintMessagesAnalysisResult (
211+ new GoblintPosition (19 , 19 , 2 , 21 , exampleUrl ),
212+ "[Race] Group: Memory location myglobal (race with conf. 110)\n " +
213+ "write with [mhp:{tid=[main]; created={[main, t_fun@src/example.c:17:3-17:40#top]}}, lock:{mutex2}, thread:[main]] (conf. 110) (exp: & myglobal)" ,
214+ "Warning" ,
215+ List .of (Pair .make (
216+ new GoblintPosition (10 , 10 , 2 , 21 , exampleUrl ),
217+ "write with [mhp:{tid=[main, t_fun@src/example.c:17:3-17:40#top]}, lock:{mutex1}, thread:[main, t_fun@src/example.c:17:3-17:40#top]] (conf. 110) (exp: & myglobal)"
218+ )
219+ )
220+ )
221+ );
222+
207223 response .add (
208224 new GoblintMessagesAnalysisResult (
209225 defaultPos ,
@@ -218,10 +234,16 @@ public void testConvertMessagesFromJsonWithExplode() throws IOException {
218234 )
219235 );
220236 verify (analysisConsumer ).consume (response , "GobPie" );
221- **/
222- }
223237
238+ }
224239
240+ /**
241+ * Mock test to ensure that the Goblint functions received from a response in JSON format
242+ * are correctly converted to {@link GoblintCFGAnalysisResult} objects
243+ * and passed to {@link MagpieServer} via {@link AnalysisConsumer}.
244+ *
245+ * @throws IOException when reading messagesResponse.json from resources fails.
246+ */
225247 @ Test
226248 public void testConvertFunctionsFromJson () throws IOException {
227249 List <GoblintFunctionsResult > goblintFunctionsResults = readGoblintResponseJsonFunc ();
@@ -258,6 +280,4 @@ public void testConvertFunctionsFromJson() throws IOException {
258280 verify (analysisConsumer ).consume (response , "GobPie" );
259281 }
260282
261-
262- }
263-
283+ }
0 commit comments