Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Removes jmockit in favor of mockito #5063

Merged
merged 4 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.scannerwork/
.vscode
*.iml
out/
Expand Down
6 changes: 3 additions & 3 deletions modules/openapi-generator-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<!-- <version>${jmockit-version}</version> -->
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,17 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.GeneratorNotFoundException;

import org.openapitools.codegen.*;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* User: lanwen Date: 24.03.15 Time: 20:22
*/

@Command(name = "generate", description = "Generate code with the specified generator.")
public class Generate implements Runnable {

// private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
CodegenConfigurator configurator;
Generator generator;

@Option(name = {"-v", "--verbose"}, description = "verbose mode")
private Boolean verbose;
Expand Down Expand Up @@ -257,13 +252,18 @@ public void run() {
.ifPresent(FilterAttachable::clearAllFilters);
}

// attempt to read from config file
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configFile);

// if a config file wasn't specified or we were unable to read it
// this initial check allows for field-level package private injection (for unit testing)
if (configurator == null) {
// createa a fresh configurator
configurator = new CodegenConfigurator();
if (configFile != null && configFile.length() > 0) {
// attempt to load from configFile
configurator = CodegenConfigurator.fromFile(configFile);
}

// if a config file wasn't specified, or we were unable to read it
if (configurator == null) {
// create a fresh configurator
configurator = new CodegenConfigurator();
}
}

// now override with any specified parameters
Expand Down Expand Up @@ -413,7 +413,14 @@ public void run() {

try {
final ClientOptInput clientOptInput = configurator.toClientOptInput();
new DefaultGenerator().opts(clientOptInput).generate();

// this null check allows us to inject for unit testing.
if (generator == null) {
generator = new DefaultGenerator();
}

generator.opts(clientOptInput);
generator.generate();
} catch (GeneratorNotFoundException e) {
System.err.println(e.getMessage());
System.err.println("[error] Check the spelling of the generator's name and try again.");
Expand Down
Loading