@@ -226,9 +226,15 @@ public void givenMapWithArrayOfEnumsThenCorrectEnumNameIsUsed() throws Exception
226226 "typescript-rxjs"
227227 );
228228
229- Pattern modelDefinition = Pattern .compile ("\\ b(interface|type|class)\\ s+EmployeeWithMultiMapOfEnum\\ b" );
230- Pattern namespacedEnumRef = Pattern .compile ("projectRoles[^\\ n]*ProjectRolesEnum" );
231- Pattern flatEnumRef = Pattern .compile ("projectRoles[^\\ n]*EmployeeWithMultiMapOfEnumProjectRolesEnum" );
229+ // Patterns for EmployeeWithMultiMapOfEnum (map of array of enums)
230+ Pattern multiMapModelDefinition = Pattern .compile ("\\ b(interface|type|class)\\ s+EmployeeWithMultiMapOfEnum\\ b" );
231+ Pattern multiMapNamespacedEnumRef = Pattern .compile ("projectRoles[^\\ n]*ProjectRolesEnum" );
232+ Pattern multiMapFlatEnumRef = Pattern .compile ("projectRoles[^\\ n]*EmployeeWithMultiMapOfEnumProjectRolesEnum" );
233+
234+ // Patterns for EmployeeWithMapOfEnum (simple map of enums)
235+ Pattern simpleMapModelDefinition = Pattern .compile ("\\ b(interface|type|class)\\ s+EmployeeWithMapOfEnum\\ b" );
236+ Pattern simpleMapNamespacedEnumRef = Pattern .compile ("projectRole[^s][^\\ n]*ProjectRoleEnum" );
237+ Pattern simpleMapFlatEnumRef = Pattern .compile ("projectRole[^s][^\\ n]*EmployeeWithMapOfEnumProjectRoleEnum" );
232238
233239 for (String generatorName : generators ) {
234240 File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
@@ -242,16 +248,29 @@ public void givenMapWithArrayOfEnumsThenCorrectEnumNameIsUsed() throws Exception
242248 Generator generator = new DefaultGenerator ();
243249 generator .opts (configurator .toClientOptInput ()).generate ();
244250
245- Path modelFile = findModelDefinitionFile (output .toPath (), modelDefinition );
246- String fileContents = Files .readString (modelFile );
251+ // Test EmployeeWithMultiMapOfEnum (map of array of enums)
252+ Path multiMapModelFile = findModelDefinitionFile (output .toPath (), multiMapModelDefinition );
253+ String multiMapFileContents = Files .readString (multiMapModelFile );
254+
255+ Assert .assertFalse (multiMapFileContents .contains ("InnerEnum" ),
256+ generatorName + ": Should not contain 'InnerEnum' reference in " + multiMapModelFile );
257+
258+ boolean hasMultiMapEnumRef = multiMapNamespacedEnumRef .matcher (multiMapFileContents ).find ()
259+ || multiMapFlatEnumRef .matcher (multiMapFileContents ).find ();
260+ Assert .assertTrue (hasMultiMapEnumRef ,
261+ generatorName + ": Expected enum reference not found in " + multiMapModelFile );
262+
263+ // Test EmployeeWithMapOfEnum (simple map of enums)
264+ Path simpleMapModelFile = findModelDefinitionFile (output .toPath (), simpleMapModelDefinition );
265+ String simpleMapFileContents = Files .readString (simpleMapModelFile );
247266
248- Assert .assertFalse (fileContents .contains ("InnerEnum" ),
249- generatorName + ": Should not contain 'InnerEnum' reference in " + modelFile );
267+ Assert .assertFalse (simpleMapFileContents .contains ("InnerEnum" ),
268+ generatorName + ": Should not contain 'InnerEnum' reference in " + simpleMapModelFile );
250269
251- boolean hasEnumRef = namespacedEnumRef .matcher (fileContents ).find ()
252- || flatEnumRef .matcher (fileContents ).find ();
253- Assert .assertTrue (hasEnumRef ,
254- generatorName + ": Expected enum reference not found in " + modelFile );
270+ boolean hasSimpleMapEnumRef = simpleMapNamespacedEnumRef .matcher (simpleMapFileContents ).find ()
271+ || simpleMapFlatEnumRef .matcher (simpleMapFileContents ).find ();
272+ Assert .assertTrue (hasSimpleMapEnumRef ,
273+ generatorName + ": Expected enum reference for simple map not found in " + simpleMapModelFile );
255274 }
256275 }
257276
0 commit comments