@@ -92,7 +92,7 @@ public void testGenerateConfig_writeToDirectory() throws Exception {
9292    }
9393
9494    @ Test 
95-     public  void  testGenerateConfig_withOutputFile () throws  Exception  {
95+     public  void  testGenerateConfig_withExplicitOutputFilename () throws  Exception  {
9696        command .setJsonWriter (mJsonWriter );
9797
9898        command .setDeclarationFile (getResourceAsPath ("/gateway/generateHeadless/plugin-and-builtin-policies.yml" ));
@@ -107,7 +107,21 @@ public void testGenerateConfig_withOutputFile() throws Exception {
107107    }
108108
109109    @ Test 
110-     public  void  testGenerateConfig_withMultipleGatewayConfigs () throws  Exception  {
110+     public  void  testGenerateConfig_withTransformedName () throws  Exception  {
111+         command .setJsonWriter (mJsonWriter );
112+ 
113+         command .setDeclarationFile (getResourceAsPath ("/gateway/generateHeadless/transform-name.yml" ));
114+         command .outputFiles .add (Paths .get ("/tmp" ));
115+         // Run 
116+         command .applyDeclaration ();
117+         // Verify 
118+         HeadlessConfigBean  expected  = expectJson ("/gateway/generateHeadless/transform-name.json" , HeadlessConfigBean .class );
119+         // Space-type characters and forward slashes should be substituted with - 
120+         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/gateway-with-various-spaces-in-original--name-and-forward-slash--.json" )), refEq (expected ));
121+     }
122+ 
123+     @ Test 
124+     public  void  testGenerateConfig_withMultipleGatewayConfigs_ExplicitName () throws  Exception  {
111125        command .setJsonWriter (mJsonWriter );
112126
113127        command .setDeclarationFile (getResourceAsPath ("/gateway/generateHeadless/plugin-and-builtin-policies_multiple-gateways.yml" ));
@@ -116,11 +130,26 @@ public void testGenerateConfig_withMultipleGatewayConfigs() throws Exception {
116130        // Run 
117131        command .applyDeclaration ();
118132        // Verify it matches our reference configs. 
119-         HeadlessConfigBean  expectedApi  = expectJson ("/gateway/generateHeadless/expected-multiple-gateways.json" , HeadlessConfigBean .class );
120-         HeadlessConfigBean  expectedApi2  = expectJson ("/gateway/generateHeadless/expected-multiple-gateways-2.json" , HeadlessConfigBean .class );
133+         HeadlessConfigBean  expectedConfig1  = expectJson ("/gateway/generateHeadless/expected-multiple-gateways.json" , HeadlessConfigBean .class );
134+         HeadlessConfigBean  expectedConfig2  = expectJson ("/gateway/generateHeadless/expected-multiple-gateways-2.json" , HeadlessConfigBean .class );
121135
122-         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/someOutputFile.json" )), refEq (expectedApi ));
123-         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/someOutputFile2.json" )), refEq (expectedApi2 ));
136+         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/someOutputFile.json" )), refEq (expectedConfig1 ));
137+         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/someOutputFile2.json" )), refEq (expectedConfig2 ));
124138    }
125139
140+     @ Test 
141+     public  void  testGenerateConfig_withMultipleGatewayConfigs_GeneratedName () throws  Exception  {
142+         command .setJsonWriter (mJsonWriter );
143+ 
144+         command .setDeclarationFile (getResourceAsPath ("/gateway/generateHeadless/plugin-and-builtin-policies_multiple-gateways.yml" ));
145+         command .outputFiles .add (Paths .get ("/tmp" )); // Directory. 
146+         // Run 
147+         command .applyDeclaration ();
148+         // Verify it matches our reference configs. 
149+         HeadlessConfigBean  expectedConfig1  = expectJson ("/gateway/generateHeadless/expected-multiple-gateways.json" , HeadlessConfigBean .class );
150+         HeadlessConfigBean  expectedConfig2  = expectJson ("/gateway/generateHeadless/expected-multiple-gateways-2.json" , HeadlessConfigBean .class );
151+ 
152+         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/test-gw-2.json" )), refEq (expectedConfig1 )); // Notice generated filenames 
153+         verify (mJsonWriter ).write (eq (Paths .get ("/tmp/test-gw.json" )), refEq (expectedConfig2 ));
154+     }
126155}
0 commit comments