1818
1919import java .io .IOException ;
2020import java .util .ArrayDeque ;
21+ import java .util .ArrayList ;
2122import java .util .Collection ;
2223import java .util .concurrent .CompletableFuture ;
2324
@@ -147,12 +148,10 @@ void preAnalyseTest() {
147148
148149 /**
149150 * * Mock test to ensure @preAnalyse function
150- * <p>
151- * <p>
152151 * is functional and is called out in @analyze function
153152 */
154153 @ Test
155- void preAnalyseEmptyString () {
154+ void preAnalyseEmpty () {
156155 // Mock everything needed for creating preAnalysis
157156 MagpieServer magpieServer = mock (MagpieServer .class );
158157 GoblintService goblintService = mock (GoblintService .class );
@@ -165,12 +164,15 @@ void preAnalyseEmptyString() {
165164 doReturn (true ).when (goblintServer ).isAlive ();
166165 when (goblintConfWatcher .refreshGoblintConfig ()).thenReturn (true );
167166
167+ // Mock that Goblint returns some messages
168+ when (goblintService .messages ()).thenReturn (CompletableFuture .completedFuture (new ArrayList <>()));
169+
168170 // Mock that the command to execute is empty
169- String [] preAnalyzeCommand = new String []{"" };
171+ String [] preAnalyzeCommand = new String []{};
170172 when (gobPieConfiguration .getPreAnalyzeCommand ()).thenReturn (preAnalyzeCommand );
171173
172174 // Mock that the analyses of Goblint have started and completed
173- when (goblintService .analyze (new AnalyzeParams (false ))).thenReturn (CompletableFuture .completedFuture (null ));
175+ when (goblintService .analyze (new AnalyzeParams (false ))).thenReturn (CompletableFuture .completedFuture (new GoblintAnalysisResult () ));
174176
175177 // Mock that the incremental analysis is turned off (TODO: not sure why this is checked in reanalyze?)
176178 when (gobPieConfiguration .useIncrementalAnalysis ()).thenReturn (true );
@@ -183,6 +185,7 @@ void preAnalyseEmptyString() {
183185 // Verify that preAnalysis was indeed called once
184186 verify (goblintServer ).preAnalyse ();
185187 verify (magpieServer ).forwardMessageToClient (new MessageParams (MessageType .Info , "GobPie started analyzing the code." ));
188+ verify (magpieServer ).forwardMessageToClient (new MessageParams (MessageType .Info , "GobPie finished analyzing the code." ));
186189 }
187190
188191 @ Test
0 commit comments