-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to set values with setApiPackage(..) and setModelPackage(..) (#…
…8013) * Add getInvokerPackage() getter * Add test cases * Handle values set with setModelPackage(..) and setApiPackage(..)
- Loading branch information
Showing
13 changed files
with
413 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...es/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientCodegenTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.swagger.codegen.android; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import io.swagger.codegen.CodegenConstants; | ||
import io.swagger.codegen.languages.AndroidClientCodegen; | ||
|
||
public class AndroidClientCodegenTest { | ||
|
||
@Test | ||
public void testInitialConfigValues() throws Exception { | ||
final AndroidClientCodegen codegen = new AndroidClientCodegen(); | ||
codegen.processOpts(); | ||
|
||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); | ||
Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); | ||
Assert.assertEquals(codegen.modelPackage(), "io.swagger.client.model"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "io.swagger.client.model"); | ||
Assert.assertEquals(codegen.apiPackage(), "io.swagger.client.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "io.swagger.client.api"); | ||
Assert.assertEquals(codegen.getInvokerPackage(), "io.swagger.client"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "io.swagger.client"); | ||
} | ||
|
||
@Test | ||
public void testSettersForConfigValues() throws Exception { | ||
final AndroidClientCodegen codegen = new AndroidClientCodegen(); | ||
codegen.setModelPackage("xx.yyyyyyyy.model"); | ||
codegen.setApiPackage("xx.yyyyyyyy.api"); | ||
codegen.setInvokerPackage("xx.yyyyyyyy.invoker"); | ||
codegen.processOpts(); | ||
|
||
Assert.assertEquals(codegen.modelPackage(), "xx.yyyyyyyy.model"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xx.yyyyyyyy.model"); | ||
Assert.assertEquals(codegen.apiPackage(), "xx.yyyyyyyy.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xx.yyyyyyyy.api"); | ||
Assert.assertEquals(codegen.getInvokerPackage(), "xx.yyyyyyyy.invoker"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xx.yyyyyyyy.invoker"); | ||
} | ||
|
||
@Test | ||
public void testAdditionalPropertiesPutForConfigValues() throws Exception { | ||
final AndroidClientCodegen codegen = new AndroidClientCodegen(); | ||
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.mmmmm.model"); | ||
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.aaaaa.api"); | ||
codegen.additionalProperties().put(CodegenConstants.INVOKER_PACKAGE,"xyz.yyyyy.iiii.invoker"); | ||
codegen.processOpts(); | ||
|
||
Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.mmmmm.model"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xyz.yyyyy.mmmmm.model"); | ||
Assert.assertEquals(codegen.apiPackage(), "xyz.yyyyy.aaaaa.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xyz.yyyyy.aaaaa.api"); | ||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.iiii.invoker"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.iiii.invoker"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...degen/src/test/java/io/swagger/codegen/java/jaxrs/AbstractJavaJAXRSServerCodegenTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.swagger.codegen.java.jaxrs; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import io.swagger.codegen.CodegenConstants; | ||
import io.swagger.codegen.CodegenType; | ||
import io.swagger.codegen.languages.AbstractJavaJAXRSServerCodegen; | ||
|
||
public class AbstractJavaJAXRSServerCodegenTest { | ||
|
||
private final AbstractJavaJAXRSServerCodegen fakeJavaJAXRSCodegen = new P_AbstractJavaJAXRSServerCodegen(); | ||
|
||
@Test | ||
public void convertApiName() throws Exception { | ||
Assert.assertEquals(fakeJavaJAXRSCodegen.toApiName("name"), "NameApi"); | ||
Assert.assertEquals(fakeJavaJAXRSCodegen.toApiName("$name"), "NameApi"); | ||
Assert.assertEquals(fakeJavaJAXRSCodegen.toApiName("nam#e"), "NameApi"); | ||
Assert.assertEquals(fakeJavaJAXRSCodegen.toApiName("$another-fake?"), "AnotherFakeApi"); | ||
Assert.assertEquals(fakeJavaJAXRSCodegen.toApiName("fake_classname_tags 123#$%^"), "FakeClassnameTags123Api"); | ||
} | ||
|
||
@Test | ||
public void testInitialConfigValues() throws Exception { | ||
final AbstractJavaJAXRSServerCodegen codegen = new P_AbstractJavaJAXRSServerCodegen(); | ||
codegen.processOpts(); | ||
|
||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); | ||
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); | ||
Assert.assertEquals(codegen.modelPackage(), "io.swagger.model"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "io.swagger.model"); | ||
Assert.assertEquals(codegen.apiPackage(), "io.swagger.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "io.swagger.api"); | ||
Assert.assertEquals(codegen.getInvokerPackage(), "io.swagger.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "io.swagger.api"); | ||
} | ||
|
||
@Test | ||
public void testSettersForConfigValues() throws Exception { | ||
final AbstractJavaJAXRSServerCodegen codegen = new P_AbstractJavaJAXRSServerCodegen(); | ||
codegen.setHideGenerationTimestamp(true); | ||
codegen.setModelPackage("xx.yyyyyyyy.model"); | ||
codegen.setApiPackage("xx.yyyyyyyy.api"); | ||
codegen.setInvokerPackage("xx.yyyyyyyy.invoker"); | ||
codegen.processOpts(); | ||
|
||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); | ||
Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); | ||
Assert.assertEquals(codegen.modelPackage(), "xx.yyyyyyyy.model"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xx.yyyyyyyy.model"); | ||
Assert.assertEquals(codegen.apiPackage(), "xx.yyyyyyyy.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xx.yyyyyyyy.api"); | ||
Assert.assertEquals(codegen.getInvokerPackage(), "xx.yyyyyyyy.invoker"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xx.yyyyyyyy.invoker"); | ||
} | ||
|
||
@Test | ||
public void testAdditionalPropertiesPutForConfigValues() throws Exception { | ||
final AbstractJavaJAXRSServerCodegen codegen = new P_AbstractJavaJAXRSServerCodegen(); | ||
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true"); | ||
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.mmmmm.model"); | ||
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.aaaaa.api"); | ||
codegen.additionalProperties().put(CodegenConstants.INVOKER_PACKAGE,"xyz.yyyyy.iiii.invoker"); | ||
codegen.processOpts(); | ||
|
||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); | ||
Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); | ||
Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.mmmmm.model"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xyz.yyyyy.mmmmm.model"); | ||
Assert.assertEquals(codegen.apiPackage(), "xyz.yyyyy.aaaaa.api"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xyz.yyyyy.aaaaa.api"); | ||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.iiii.invoker"); | ||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.iiii.invoker"); | ||
} | ||
|
||
private static class P_AbstractJavaJAXRSServerCodegen extends AbstractJavaJAXRSServerCodegen { | ||
|
||
@Override | ||
public CodegenType getTag() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getHelp() { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.