@@ -34,6 +34,10 @@ class GobPieConfTest {
3434 MagpieServer magpieServer ;
3535 GobPieConfReader gobPieConfReader ;
3636
37+ /*
38+ * A function that mocks MagpieServer, gets absolute
39+ * file path and returns new GobPieConfReader.
40+ */
3741 GobPieConfReader preFileSetup (Integer fileNumber ) {
3842 // Mock everything needed for creating GobPieConfReader
3943 MagpieServer magpieServer = mock (MagpieServer .class );
@@ -42,6 +46,10 @@ GobPieConfReader preFileSetup(Integer fileNumber) {
4246 return new GobPieConfReader (magpieServer , gobPieConfFileName );
4347 }
4448
49+ /*
50+ * Mock test to ensure @readGobPieConfiguration function
51+ * reads GobPie configuration
52+ */
4553 @ Test
4654 void testReadGobPieConfiguration () {
4755 gobPieConfReader = preFileSetup (1 );
@@ -57,12 +65,14 @@ void testReadGobPieConfiguration() {
5765 .createGobPieConfiguration ();
5866
5967 GobPieConfiguration actualGobPieConfiguration = gobPieConfReader .readGobPieConfiguration ();
60-
6168 assertTrue (systemOut .getLines ().anyMatch (line -> line .contains ("Reading GobPie configuration from json" )));
6269 assertTrue (systemOut .getLines ().anyMatch (line -> line .contains ("GobPie configuration read from json" )));
6370 assertEquals (expectedGobPieConfiguration , actualGobPieConfiguration );
6471 }
65-
72+ /*
73+ * Mock test to ensure @readGobPieConfiguration function
74+ * reads Complete GobPie configuration with different Boolean values
75+ */
6676 @ Test
6777 void testReadCompleteGobPieConfiguration () {
6878 gobPieConfReader = preFileSetup (2 );
@@ -83,6 +93,10 @@ void testReadCompleteGobPieConfiguration() {
8393 assertEquals (expectedGobPieConfiguration , actualGobPieConfiguration );
8494 }
8595
96+ /*
97+ * Mock test to ensure @readGobPieConfiguration function
98+ * accurately retrieves default values
99+ */
86100 @ Test
87101 void testGobPieConfigurationDefaultValues () {
88102 gobPieConfReader = preFileSetup (3 );
@@ -102,14 +116,21 @@ void testGobPieConfigurationDefaultValues() {
102116 assertTrue (systemOut .getLines ().anyMatch (line -> line .contains ("GobPie configuration read from json" )));
103117 assertEquals (expectedGobPieConfiguration , actualGobPieConfiguration );
104118 }
105-
119+ /*
120+ * Mock test to ensure @readGobPieConfiguration function
121+ * throws an exception when there is a syntax error in the JSON
122+ */
106123 @ Test
107124 void testReadGobPieConfigurationWithWrongJSONSyntax () {
108125 gobPieConfReader = preFileSetup (4 );
109126 GobPieException thrown = assertThrows (GobPieException .class , gobPieConfReader ::readGobPieConfiguration );
110127 assertEquals ("GobPie configuration file syntax is wrong." , thrown .getMessage ());
111128 }
112129
130+ /*
131+ * Mock test to ensure @readGobPieConfiguration function
132+ * checks for the presence of an unexpected field in the configuration
133+ */
113134 @ Test
114135 void testReadGobPieConfigurationWithExtraField () {
115136 gobPieConfReader = preFileSetup (5 );
@@ -130,8 +151,14 @@ void testReadGobPieConfigurationWithExtraField() {
130151 assertEquals (expectedGobPieConfiguration , actualGobPieConfiguration );
131152 }
132153
154+ /*
155+ * Mock test to ensure @readGobPieConfiguration function
156+ * messages user when the configuration file is absent
157+ * in the root directory
158+ */
133159 @ Test
134160 void testGobPieConfigurationFileMissingInRoot () throws IOException , ExecutionException , InterruptedException {
161+ // Mock everything needed for creating GobPieConfReader
135162 MagpieServer magpieServer = mock (MagpieServer .class );
136163 Path tempGobpieConfFilePath = tempDir .resolve ("gobpieTestTemp1.json" );
137164 GobPieConfReader gobPieConfReader = new GobPieConfReader (magpieServer , tempGobpieConfFilePath .toString ());
@@ -172,13 +199,17 @@ void testGobPieConfigurationFileMissingInRoot() throws IOException, ExecutionExc
172199 }
173200 }
174201
202+ /*
203+ * Mock test to ensure @readGobPieConfiguration function
204+ *
205+ */
175206 @ Test
176207 void testGobPieConfigurationWithoutGoblintConfField () throws IOException , ExecutionException , InterruptedException {
208+ // Mock everything needed for creating GobPieConfReader
177209 MagpieServer magpieServer = mock (MagpieServer .class );
178210 Path tempGobpieConfFilePath = tempDir .resolve ("gobpieTestTemp2.json" );
179211 GobPieConfReader gobPieConfReader = new GobPieConfReader (magpieServer , tempGobpieConfFilePath .toString ());
180212
181-
182213 GobPieConfiguration .Builder builder = new GobPieConfiguration .Builder ()
183214 .setGoblintExecutable ("/home/user/goblint/analyzer/goblint" )
184215 .setPreAnalyzeCommand (new String []{"echo" , "'hello'" })
@@ -220,11 +251,18 @@ void testGobPieConfigurationWithoutGoblintConfField() throws IOException, Execut
220251 }
221252 }
222253
254+ /*
255+ * Mock test to ensure @readGobPieConfiguration function
256+ * messages user when goblintConf parameter is missing
257+ * from GobPie configuration file.
258+ */
223259 @ Test
224260 void testGobPieConfigurationWithoutGoblintConfField2 () throws ExecutionException , InterruptedException {
261+ // Mock everything needed for creating GobPieConfReader
225262 MagpieServer magpieServer = mock (MagpieServer .class );
226263 String gobPieConfFileName = GobPieConfTest .class .getResource ("gobpieTest6.json" ).getFile ();
227264 GobPieConfReader gobPieConfReader = new GobPieConfReader (magpieServer , gobPieConfFileName );
265+
228266 CompletableFuture <GobPieConfiguration > future = CompletableFuture .supplyAsync (gobPieConfReader ::readGobPieConfiguration );
229267
230268 // Assert that the configuration was read;
0 commit comments