Skip to content
Permalink
Browse files

[test] Removes jmockit in favor of mockito (#5063)

* [test] Removes jmockit in favor of mockito

We use mockito in many tests. This removes jmockit which is run as a
javaagent in favor of Mockito which is not.

This work is in preparation for applying some static analysis tools,
while evaluating others such as Jacoco. I'm also look at ways to improve
build times while also decreasing "ramp up time" for contributions from
the community. Reducing the number of mock frameworks and dependencies
is a step toward that goal.

* Rename method in new.sh

* [cli] Mock the generate task
  • Loading branch information
jimschubert committed Jan 22, 2020
1 parent bf57a99 commit ac528aaf07978ac722c6da5435cbda16aba9115f
Showing with 642 additions and 1,020 deletions.
  1. +1 −0 .gitignore
  2. +3 −3 modules/openapi-generator-cli/pom.xml
  3. +23 −16 modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java
  4. +292 −411 modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/GenerateTest.java
  5. +1 −7 modules/openapi-generator/pom.xml
  6. +12 −8 modules/openapi-generator/src/test/java/org/openapitools/codegen/AbstractOptionsTest.java
  7. +16 −28 modules/openapi-generator/src/test/java/org/openapitools/codegen/bash/BashClientOptionsTest.java
  8. +15 −28 modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientOptionsTest.java
  9. +17 −32 ...es/openapi-generator/src/test/java/org/openapitools/codegen/dartdio/DartDioClientOptionsTest.java
  10. +6 −9 modules/openapi-generator/src/test/java/org/openapitools/codegen/elixir/ElixirClientOptionsTest.java
  11. +14 −25 modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientOptionsTest.java
  12. +8 −14 ...pi-generator/src/test/java/org/openapitools/codegen/haskellservant/HaskellServantOptionsTest.java
  13. +13 −24 ...les/openapi-generator/src/test/java/org/openapitools/codegen/lumen/PhpLumenServerOptionsTest.java
  14. +8 −14 modules/openapi-generator/src/test/java/org/openapitools/codegen/mysql/MysqlSchemaOptionsTest.java
  15. +11 −20 modules/openapi-generator/src/test/java/org/openapitools/codegen/objc/ObjcClientOptionsTest.java
  16. +1 −1 ...napi-generator/src/test/java/org/openapitools/codegen/options/ScalaHttpClientOptionsProvider.java
  17. +8 −14 modules/openapi-generator/src/test/java/org/openapitools/codegen/perl/PerlClientOptionsTest.java
  18. +13 −24 modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientOptionsTest.java
  19. +13 −26 modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientOptionsTest.java
  20. +15 −29 modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientOptionsTest.java
  21. +6 −8 ...pi-generator/src/test/java/org/openapitools/codegen/rubysinatra/RubySinatraServerOptionsTest.java
  22. +11 −20 ...penapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientOptionsTest.java
  23. +11 −20 ...-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientOptionsTest.java
  24. +6 −10 ...les/openapi-generator/src/test/java/org/openapitools/codegen/silex/PhpSilexServerOptionsTest.java
  25. +13 −24 modules/openapi-generator/src/test/java/org/openapitools/codegen/slim/PhpSlimServerOptionsTest.java
  26. +14 −26 ...les/openapi-generator/src/test/java/org/openapitools/codegen/slim4/PhpSlim4ServerOptionsTest.java
  27. +12 −22 modules/openapi-generator/src/test/java/org/openapitools/codegen/swift3/Swift3OptionsTest.java
  28. +13 −24 modules/openapi-generator/src/test/java/org/openapitools/codegen/swift4/Swift4OptionsTest.java
  29. +12 −22 modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5OptionsTest.java
  30. +9 −16 ...src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java
  31. +10 −18 ...tor/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
  32. +10 −18 ...ava/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
  33. +9 −16 ...org/openapitools/codegen/typescript/typescriptangularjs/TypeScriptAngularJsClientOptionsTest.java
  34. +9 −16 ...test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
  35. +6 −10 new.sh
  36. +1 −17 pom.xml
@@ -1,3 +1,4 @@
.scannerwork/
.vscode
*.iml
out/
@@ -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>
@@ -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;
@@ -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
@@ -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.");

0 comments on commit ac528aa

Please sign in to comment.
You can’t perform that action at this time.