@@ -211,18 +211,23 @@ void toApiName_shouldReturnDefaultNameForEmptyString() {
211211 @ Test
212212 void processOpts_shouldRemoveApiUtilSupportingFileWhenNotUsed () {
213213 BoatWebhooksCodeGen codegen = new BoatWebhooksCodeGen ();
214- // Add ApiUtil supporting file
215- codegen .supportingFiles ().add (new SupportingFile ("apiUtil.mustache" , "dir" , "ApiUtil.java" ));
216- // Simulate configuration to NOT use ApiUtil
214+ var outputDir = TEST_OUTPUT + "/supportingFilesTest" ;
215+ codegen .supportingFiles ().add (new SupportingFile ("apiUtil.mustache" , outputDir , "ApiUtil.java" ));
217216 codegen .additionalProperties ().put ("generateSupportingFiles" , false );
218- // Set up the global property to simulate the absence of ApiUtil
219- org .openapitools .codegen .config .GlobalSettings .setProperty ("supportingFiles" , "" );
220- // Execute processOpts (which contains the selected lines)
221- codegen .processOpts ();
222- // Assert that ApiUtil supporting file is removed
223- boolean apiUtilPresent = codegen .supportingFiles ().stream ()
224- .anyMatch (sf -> "apiUtil.mustache" .equals (sf .getTemplateFile ()));
225- assertEquals (false , apiUtilPresent );
217+ String originalSupportingFiles = org .openapitools .codegen .config .GlobalSettings .getProperty ("supportingFiles" );
218+ try {
219+ org .openapitools .codegen .config .GlobalSettings .setProperty ("supportingFiles" , "" );
220+ codegen .processOpts ();
221+ boolean apiUtilPresent = codegen .supportingFiles ().stream ()
222+ .anyMatch (sf -> "apiUtil.mustache" .equals (sf .getTemplateFile ()));
223+ assertEquals (false , apiUtilPresent );
224+ } finally {
225+ if (originalSupportingFiles != null ) {
226+ org .openapitools .codegen .config .GlobalSettings .setProperty ("supportingFiles" , originalSupportingFiles );
227+ } else {
228+ org .openapitools .codegen .config .GlobalSettings .clearProperty ("supportingFiles" );
229+ }
230+ }
226231 }
227232
228233
0 commit comments