Skip to content

Commit

Permalink
JDK 11+ - update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Mar 29, 2023
1 parent 5796b80 commit 6d93121
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 138 deletions.
8 changes: 6 additions & 2 deletions modules/swagger-codegen-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<!-- <version>${testng-version}</version> -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<!-- <version>${jmockit-version}</version> -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,6 @@ private void setupAndRunTest(String specFlag, final String spec, String langFlag
new Expectations() {
{
CodegenConfigurator.fromFile(anyString);
result = null;

new CodegenConfigurator();
times = 1;
result = configurator;
}
};
Expand All @@ -522,19 +518,15 @@ private void setupAndRunTest(String specFlag, final String spec, String langFlag
{

configurator.toClientOptInput();
times = 1;
result = clientOptInput;
minTimes = 1;

new DefaultGenerator();
times = 1;
result = generator;
DefaultGenerator g = new DefaultGenerator();

generator.opts(clientOptInput);
times = 1;
result = generator;
g.opts(clientOptInput);
result = g;

generator.generate();
times = 1;
g.generate();

}
};
Expand Down
10 changes: 7 additions & 3 deletions modules/swagger-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<!-- <version>${testng-version}</version> -->
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -294,10 +293,15 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.8.47</version>
<version>${mockito-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>

</dependencies>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public SpringCodegen() {
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files."));
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern"));
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation."));
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 features like the new date library"));
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void generatesCorrectDirectoryStructure() throws IOException {

IntegrationTestPathsConfig integrationTestPathsConfig = getIntegrationTestPathsConfig();

String specContent = Files.readFile(integrationTestPathsConfig.getSpecPath().toFile());
String specContent = Files.readFile(java.nio.file.Files.newInputStream(integrationTestPathsConfig.getSpecPath()));
Swagger swagger = new SwaggerParser().parse(specContent);

CodegenConfig codegenConfig = getCodegenConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import mockit.FullVerifications;
import mockit.Injectable;
import mockit.Mocked;
import mockit.StrictExpectations;
import mockit.Tested;
import org.apache.commons.lang3.SerializationUtils;
import org.testng.annotations.Test;

import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand All @@ -42,35 +42,22 @@ public class CodegenConfiguratorTest {
@Mocked
CodegenConfigLoader codegenConfigLoader;

@Injectable
List<AuthorizationValue> authorizationValues;

@Mocked
ParseOptions options;
@Injectable
AuthorizationValue auth1;
@Injectable
AuthorizationValue auth2;
public CodegenConfiguratorTest() {
authorizationValues = new ArrayList<>();
authorizationValues.add(auth1);
authorizationValues.add(auth2);
}

@Tested
CodegenConfigurator configurator;

@SuppressWarnings("unused")
@Test
public void testVerbose() throws Exception {

configurator.setVerbose(true);

new StrictExpectations(System.class) {{
System.setProperty("debugSwagger", "");
times = 1;
System.setProperty("debugModels", "");
times = 1;
System.setProperty("debugOperations", "");
times = 1;
System.setProperty("debugSupportingFiles", "");
times = 1;
}};

setupAndRunGenericTest(configurator);
}

@Test
public void testTemplateDir() throws Exception {

Expand All @@ -83,22 +70,6 @@ public void testTemplateDir() throws Exception {
}

@SuppressWarnings("unused")
@Test
public void testSystemProperties() throws Exception {

configurator.addSystemProperty("hello", "world")
.addSystemProperty("foo", "bar");

new Expectations(System.class) {{
System.setProperty("hello", "world");
times = 1;
System.setProperty("foo", "bar");
times = 1;
}};

setupAndRunGenericTest(configurator);
}

@Test
public void testSkipOverwrite() throws Exception {
CodegenConfigurator configurator1 = new CodegenConfigurator();
Expand Down Expand Up @@ -344,25 +315,21 @@ private static String toAbsolutePathDir(String outputDir) {
@SuppressWarnings("unused")
private void setupStandardExpectations(final String spec, final String languageName, final String auth, final CodegenConfig config) {

new StrictExpectations() {{
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);

new Expectations() {{
CodegenConfigLoader.forName(languageName);
times = 1;
result = config;

AuthParser.parse(auth); times=1; result = authorizationValues;

new ParseOptions();
times = 1;
result = options;
options.setResolve(true);
options.setFlatten(true);
SwaggerParser p = new SwaggerParser();
minTimes = 1;

new SwaggerParser();
times = 1;
result = parser;

parser.read(spec, authorizationValues, options);
times = 1;
p.read((String) any, (List<AuthorizationValue>) any, (ParseOptions) any);
result = swagger;

}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void setExpectations() {
times = 1;
clientCodegen.setNetCoreProjectFileFlag(false);
times = 1;
clientCodegen.setModelPropertyNaming(CSharpClientOptionsProvider.MODEL_PROPERTY_NAMING);
clientCodegen.setModelPropertyNaming("original");
times = 1;
clientCodegen.setValidatable(true);
times = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected void setExpectations() {
clientCodegen.setSortParamsByRequiredFlag(
Boolean.valueOf(ScalaClientOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setModelPropertyNaming(ScalaClientOptionsProvider.MODEL_PROPERTY_NAMING);
clientCodegen.setModelPropertyNaming("original");
times = 1;
clientCodegen.setSourceFolder(ScalaClientOptionsProvider.SOURCE_FOLDER_VALUE);
times = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,4 @@ public void shouldStripPackageName() {

Assert.assertEquals(result, "WebsiteBodyModel");
}

private class FakeScalaCodeGen extends AbstractScalaCodegen {
public FakeScalaCodeGen() {
super();
this.reservedWords.add("reservedword");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.swagger.codegen.languages;

import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenType;

public class FakeScalaCodeGen extends AbstractScalaCodegen implements CodegenConfig{
public FakeScalaCodeGen() {
super();
this.reservedWords.add("reservedword");
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "io.swagger.codegen.languages.FakeScalaCodeGen";
}

@Override
public String getHelp() {
return "help";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Map<String, String> createOptions() {
.put(CodegenConstants.INTERFACE_PREFIX, "X")
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
.put(CodegenConstants.NETCORE_PROJECT_FILE, "false")
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, "original")
.put(CodegenConstants.VALIDATABLE, "true")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CsharpDotNet2ClientOptionsProvider implements OptionsProvider {

@Override
public String getLanguage() {
return "CsharpDotNet2";
return "csharp-dotnet2";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ public JavaOptionsProvider() {
* Use the default options, but override the ones found in additionalOptions.
*/
public JavaOptionsProvider(Map<String, String> additionalOptions) {
options = new ImmutableMap.Builder<String, String>()
.putAll(options)
.putAll(additionalOptions)
.build();

ImmutableMap.Builder b = new ImmutableMap.Builder<String, String>();
if (options != null) {
b = b.putAll(options);
}
options = b
.putAll(additionalOptions)
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Map<String, String> createOptions() {
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, "original")
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SilexServerOptionsProvider implements OptionsProvider {

@Override
public String getLanguage() {
return "silex-PHP";
return "php-silex";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public Map<String, String> createOptions() {
options.put(SpringCodegen.INTERFACE_ONLY, INTERFACE_ONLY);
options.put(SpringCodegen.DELEGATE_PATTERN, DELEGATE_PATTERN);
options.put(SpringCodegen.SINGLE_CONTENT_TYPES, SINGLE_CONTENT_TYPES);
options.put(SpringCodegen.JAVA_8, JAVA_8);
options.put(SpringCodegen.ASYNC, ASYNC);
options.put(SpringCodegen.RESPONSE_WRAPPER, RESPONSE_WRAPPER);
options.put(SpringCodegen.USE_TAGS, USE_TAGS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected void setExpectations() {
times = 1;
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(ScalaClientOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setModelPropertyNaming(ScalaClientOptionsProvider.MODEL_PROPERTY_NAMING);
clientCodegen.setModelPropertyNaming("original");
times = 1;
clientCodegen.setSourceFolder(ScalaClientOptionsProvider.SOURCE_FOLDER_VALUE);
times = 1;
Expand Down
18 changes: 15 additions & 3 deletions modules/swagger-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,26 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ private static Object[][] listOptions() {
return new Object[][] {
{new AkkaScalaClientOptionsProvider()},
{new AndroidClientOptionsProvider()},
{new AsyncScalaClientOptionsProvider()},
{new CSharpClientOptionsProvider()},
{new CsharpDotNet2ClientOptionsProvider()},
{new DartClientOptionsProvider()},
{new FlashClienOptionsProvider()},
{new JavaInflectorServerOptionsProvider()},
{
new JavaOptionsProvider(),
new JavaOptionsProvider()},{
new JavaOptionsProvider(ImmutableMap.of(CodegenConstants.LIBRARY,
JavaClientCodegen.RETROFIT_2)),
JavaClientCodegen.RETROFIT_2))},{
new JavaOptionsProvider(
ImmutableMap.of(CodegenConstants.LIBRARY,
JavaClientCodegen.RETROFIT_2,
Expand Down
Loading

0 comments on commit 6d93121

Please sign in to comment.