Skip to content

Commit

Permalink
reverted "e23815" commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMario committed Mar 30, 2018
1 parent c2d2cf7 commit aa9e90b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,15 @@ public void processOpts() {

if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
} else if (StringUtils.isNotEmpty(modelPackage)) {
// not set in additionalProperties, add value from CodegenConfig in order to use it in templates
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
}

if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
this.setApiPackage((String) additionalProperties.get(CodegenConstants.API_PACKAGE));
} else if (StringUtils.isNotEmpty(apiPackage)) {
// not set in additionalProperties, add value from CodegenConfig in order to use it in templates
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
}

if (additionalProperties.containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) {
this.setSortParamsByRequiredFlag(Boolean.valueOf(additionalProperties
.get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString()));
} else if (sortParamsByRequiredFlag != null) {
// not set in additionalProperties, add value from CodegenConfig in order to use it in templates
additionalProperties.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, sortParamsByRequiredFlag);
}

if (additionalProperties.containsKey(CodegenConstants.ENSURE_UNIQUE_PARAMS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ public AbstractJavaCodegen() {

@Override
public void processOpts() {
super.processOpts();

modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
apiTestTemplateFiles.put("api_test.mustache", ".java");
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");

if (additionalProperties.containsKey(SUPPORT_JAVA6)) {
this.setSupportJava6(Boolean.valueOf(additionalProperties.get(SUPPORT_JAVA6).toString()));
}
additionalProperties.put(SUPPORT_JAVA6, supportJava6);


if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
} else if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
Expand All @@ -186,19 +200,6 @@ public void processOpts() {
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
}

super.processOpts();

modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
apiTestTemplateFiles.put("api_test.mustache", ".java");
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");

if (additionalProperties.containsKey(SUPPORT_JAVA6)) {
this.setSupportJava6(Boolean.valueOf(additionalProperties.get(SUPPORT_JAVA6).toString()));
}
additionalProperties.put(SUPPORT_JAVA6, supportJava6);

if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) {
this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID));
} else if(StringUtils.isNotEmpty(groupId)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.swagger.codegen.languages;

import io.swagger.codegen.CodegenArgument;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenType;
import org.testng.Assert;
import org.testng.annotations.Test;
Expand All @@ -15,13 +14,8 @@ public void testInitialValues() throws Exception {
codegen.processOpts();

Assert.assertEquals(codegen.modelPackage, "");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), null);
Assert.assertEquals(codegen.apiPackage, "");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), null);
Assert.assertEquals(codegen.sortParamsByRequiredFlag, Boolean.TRUE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG), Boolean.TRUE);
Assert.assertEquals(codegen.hideGenerationTimestamp, Boolean.TRUE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
}

@Test
Expand All @@ -34,32 +28,8 @@ public void testSetters() throws Exception {
codegen.processOpts();

Assert.assertEquals(codegen.modelPackage, "xxx.yyyyy.zzzzzzz.model");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xxx.yyyyy.zzzzzzz.model");
Assert.assertEquals(codegen.apiPackage, "xxx.yyyyy.zzzzzzz.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xxx.yyyyy.zzzzzzz.api");
Assert.assertEquals(codegen.sortParamsByRequiredFlag, Boolean.FALSE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG), Boolean.FALSE);
Assert.assertEquals(codegen.hideGenerationTimestamp, Boolean.FALSE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
}

@Test
public void testPutAdditionalProperties() throws Exception {
final DefaultCodegenConfig codegen = new P_DefaultCodegenConfig();
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xx.yyyyy.model");
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xx.yyyyy.api");
codegen.additionalProperties().put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, false);
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
codegen.processOpts();

Assert.assertEquals(codegen.modelPackage, "xx.yyyyy.model");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xx.yyyyy.model");
Assert.assertEquals(codegen.apiPackage, "xx.yyyyy.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xx.yyyyy.api");
Assert.assertEquals(codegen.sortParamsByRequiredFlag, Boolean.FALSE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG), Boolean.FALSE);
Assert.assertEquals(codegen.hideGenerationTimestamp, Boolean.FALSE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
}

private static class P_DefaultCodegenConfig extends DefaultCodegenConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ public void testInitialPackageNamesValues() throws Exception {
codegen.processOpts();

Assert.assertEquals(codegen.modelPackage(), "invalidPackageName");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), null);
Assert.assertEquals(codegen.apiPackage(), "invalidPackageName");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), null);

Assert.assertEquals(codegen.invokerPackage, "io.swagger");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "io.swagger");
}

@Test
Expand All @@ -128,13 +126,10 @@ public void testPackageNamesSetWithSetters() throws Exception {
codegen.processOpts();

Assert.assertEquals(codegen.modelPackage(), "xxx.yyyyy.zzzzzzz.model");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xxx.yyyyy.zzzzzzz.model");
Assert.assertEquals(codegen.apiPackage(), "xxx.yyyyy.zzzzzzz.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xxx.yyyyy.zzzzzzz.api");
Assert.assertEquals(codegen.invokerPackage, "xxx.yyyyy.zzzzzzz.invoker");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xxx.yyyyy.zzzzzzz.invoker");
Assert.assertEquals(codegen.getSortParamsByRequiredFlag(), Boolean.FALSE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG), Boolean.FALSE);
}

@Test
Expand All @@ -153,7 +148,6 @@ public void testPackageNamesSetWithAdditionalProperties() throws Exception {
Assert.assertEquals(codegen.invokerPackage, "xxx.yyyyy.invoker.xxxxxx");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xxx.yyyyy.invoker.xxxxxx");
Assert.assertEquals(codegen.getSortParamsByRequiredFlag(), Boolean.TRUE);
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG), Boolean.TRUE);
}

public static class P_AbstractJavaCodegen extends AbstractJavaCodegen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public void testInitialPackageNamesValues() throws Exception {
codegen.processOpts();

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.invokerPackage, "io.swagger.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "io.swagger.api");
}
Expand All @@ -42,9 +40,7 @@ public void testPackageNamesSetWithSetters() throws Exception {
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.invokerPackage, "xx.yyyyyyyy.invoker");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xx.yyyyyyyy.invoker");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ public void testInitialPackageNamesValues() throws Exception {
codegen.processOpts();

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.invokerPackage, "io.swagger.client");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "io.swagger.client");
}
Expand All @@ -197,9 +195,7 @@ public void testPackageNamesSetWithSetters() throws Exception {
codegen.processOpts();

Assert.assertEquals(codegen.modelPackage(), "xxx.yyyyy.zzzzzzz.model");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xxx.yyyyy.zzzzzzz.model");
Assert.assertEquals(codegen.apiPackage(), "xxx.yyyyy.zzzzzzz.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xxx.yyyyy.zzzzzzz.api");
Assert.assertEquals(codegen.invokerPackage, "xxx.yyyyy.zzzzzzz.invoker");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xxx.yyyyy.zzzzzzz.invoker");
}
Expand Down Expand Up @@ -244,7 +240,6 @@ public void testPackageNamesSetInvokerDerivedFromModel() throws Exception {
Assert.assertEquals(codegen.modelPackage(), "xxx.yyyyy.zzzzzzz.mmmmm.model");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "xxx.yyyyy.zzzzzzz.mmmmm.model");
Assert.assertEquals(codegen.apiPackage(), "io.swagger.client.api");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "io.swagger.client.api");
Assert.assertEquals(codegen.invokerPackage, "xxx.yyyyy.zzzzzzz.mmmmm");
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xxx.yyyyy.zzzzzzz.mmmmm");
}
Expand Down

0 comments on commit aa9e90b

Please sign in to comment.