Skip to content
Permalink
Browse files

Add auto-generated tests and travis config to Dart clients (#3006)

* add auto-generated tests and travis config for dart

* improve tests

* fix tests

* add test, travis files to dart jaguar generator
  • Loading branch information...
wing328 committed May 27, 2019
1 parent 5c6824f commit b88b1d656a776ae634c93ab9839d6f6cecee1614
Showing with 4,388 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +26 −0 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
  3. +1 −0 ...s/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
  4. +28 −0 modules/openapi-generator/src/main/resources/dart-jaguar/api_test.mustache
  5. +26 −0 modules/openapi-generator/src/main/resources/dart-jaguar/model_test.mustache
  6. +11 −0 modules/openapi-generator/src/main/resources/dart-jaguar/travis.mustache
  7. +28 −0 modules/openapi-generator/src/main/resources/dart/api_test.mustache
  8. +26 −0 modules/openapi-generator/src/main/resources/dart/model_test.mustache
  9. +2 −0 modules/openapi-generator/src/main/resources/dart/pubspec.mustache
  10. +11 −0 modules/openapi-generator/src/main/resources/dart/travis.mustache
  11. +28 −0 modules/openapi-generator/src/main/resources/dart2/api_test.mustache
  12. +26 −0 modules/openapi-generator/src/main/resources/dart2/model_test.mustache
  13. +2 −0 modules/openapi-generator/src/main/resources/dart2/pubspec.mustache
  14. +11 −0 modules/openapi-generator/src/main/resources/dart2/travis.mustache
  15. +1 −1 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/.openapi-generator/VERSION
  16. +11 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/.travis.yml
  17. +1 −1 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md
  18. +27 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/api_response_test.dart
  19. +22 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/category_test.dart
  20. +43 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/order_test.dart
  21. +73 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/pet_api_test.dart
  22. +43 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/pet_test.dart
  23. +45 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/store_api_test.dart
  24. +22 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/tag_test.dart
  25. +73 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/user_api_test.dart
  26. +53 −0 samples/client/petstore/dart-jaguar/flutter_petstore/openapi/test/user_test.dart
  27. +1 −1 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/.openapi-generator/VERSION
  28. +11 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/.travis.yml
  29. +1 −1 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/README.md
  30. +27 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/api_response_test.dart
  31. +22 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/category_test.dart
  32. +43 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/order_test.dart
  33. +73 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/pet_api_test.dart
  34. +43 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/pet_test.dart
  35. +45 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/store_api_test.dart
  36. +22 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/tag_test.dart
  37. +73 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/user_api_test.dart
  38. +53 −0 samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/test/user_test.dart
  39. +1 −1 samples/client/petstore/dart-jaguar/openapi/.openapi-generator/VERSION
  40. +11 −0 samples/client/petstore/dart-jaguar/openapi/.travis.yml
  41. +1 −1 samples/client/petstore/dart-jaguar/openapi/README.md
  42. +27 −0 samples/client/petstore/dart-jaguar/openapi/test/api_response_test.dart
  43. +22 −0 samples/client/petstore/dart-jaguar/openapi/test/category_test.dart
  44. +43 −0 samples/client/petstore/dart-jaguar/openapi/test/order_test.dart
  45. +73 −0 samples/client/petstore/dart-jaguar/openapi/test/pet_api_test.dart
  46. +43 −0 samples/client/petstore/dart-jaguar/openapi/test/pet_test.dart
  47. +45 −0 samples/client/petstore/dart-jaguar/openapi/test/store_api_test.dart
  48. +22 −0 samples/client/petstore/dart-jaguar/openapi/test/tag_test.dart
  49. +73 −0 samples/client/petstore/dart-jaguar/openapi/test/user_api_test.dart
  50. +53 −0 samples/client/petstore/dart-jaguar/openapi/test/user_test.dart
  51. +1 −1 samples/client/petstore/dart-jaguar/openapi_proto/.openapi-generator/VERSION
  52. +11 −0 samples/client/petstore/dart-jaguar/openapi_proto/.travis.yml
  53. +1 −1 samples/client/petstore/dart-jaguar/openapi_proto/README.md
  54. +27 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/api_response_test.dart
  55. +22 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/category_test.dart
  56. +43 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/order_test.dart
  57. +73 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/pet_api_test.dart
  58. +43 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/pet_test.dart
  59. +45 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/store_api_test.dart
  60. +22 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/tag_test.dart
  61. +73 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/user_api_test.dart
  62. +53 −0 samples/client/petstore/dart-jaguar/openapi_proto/test/user_test.dart
  63. +1 −1 samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION
  64. +11 −0 samples/client/petstore/dart/flutter_petstore/openapi/.travis.yml
  65. +2 −0 samples/client/petstore/dart/flutter_petstore/openapi/pubspec.yaml
  66. +27 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/api_response_test.dart
  67. +22 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/category_test.dart
  68. +43 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/order_test.dart
  69. +73 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/pet_api_test.dart
  70. +43 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/pet_test.dart
  71. +45 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/store_api_test.dart
  72. +22 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/tag_test.dart
  73. +73 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/user_api_test.dart
  74. +53 −0 samples/client/petstore/dart/flutter_petstore/openapi/test/user_test.dart
  75. +1 −1 samples/client/petstore/dart/openapi-browser-client/.openapi-generator/VERSION
  76. +11 −0 samples/client/petstore/dart/openapi-browser-client/.travis.yml
  77. +2 −0 samples/client/petstore/dart/openapi-browser-client/pubspec.yaml
  78. +27 −0 samples/client/petstore/dart/openapi-browser-client/test/api_response_test.dart
  79. +22 −0 samples/client/petstore/dart/openapi-browser-client/test/category_test.dart
  80. +43 −0 samples/client/petstore/dart/openapi-browser-client/test/order_test.dart
  81. +73 −0 samples/client/petstore/dart/openapi-browser-client/test/pet_api_test.dart
  82. +43 −0 samples/client/petstore/dart/openapi-browser-client/test/pet_test.dart
  83. +45 −0 samples/client/petstore/dart/openapi-browser-client/test/store_api_test.dart
  84. +22 −0 samples/client/petstore/dart/openapi-browser-client/test/tag_test.dart
  85. +73 −0 samples/client/petstore/dart/openapi-browser-client/test/user_api_test.dart
  86. +53 −0 samples/client/petstore/dart/openapi-browser-client/test/user_test.dart
  87. +1 −1 samples/client/petstore/dart/openapi/.openapi-generator/VERSION
  88. +11 −0 samples/client/petstore/dart/openapi/.travis.yml
  89. +2 −0 samples/client/petstore/dart/openapi/pubspec.yaml
  90. +27 −0 samples/client/petstore/dart/openapi/test/api_response_test.dart
  91. +22 −0 samples/client/petstore/dart/openapi/test/category_test.dart
  92. +43 −0 samples/client/petstore/dart/openapi/test/order_test.dart
  93. +73 −0 samples/client/petstore/dart/openapi/test/pet_api_test.dart
  94. +43 −0 samples/client/petstore/dart/openapi/test/pet_test.dart
  95. +45 −0 samples/client/petstore/dart/openapi/test/store_api_test.dart
  96. +22 −0 samples/client/petstore/dart/openapi/test/tag_test.dart
  97. +73 −0 samples/client/petstore/dart/openapi/test/user_api_test.dart
  98. +53 −0 samples/client/petstore/dart/openapi/test/user_test.dart
  99. +6 −0 samples/client/petstore/dart/purge_test.sh
  100. +1 −1 samples/client/petstore/dart2/flutter_petstore/openapi/.openapi-generator/VERSION
  101. +11 −0 samples/client/petstore/dart2/flutter_petstore/openapi/.travis.yml
  102. +3 −1 samples/client/petstore/dart2/flutter_petstore/openapi/pubspec.yaml
  103. +27 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/api_response_test.dart
  104. +22 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/category_test.dart
  105. +43 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/order_test.dart
  106. +73 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/pet_api_test.dart
  107. +43 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/pet_test.dart
  108. +45 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/store_api_test.dart
  109. +22 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/tag_test.dart
  110. +73 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/user_api_test.dart
  111. +53 −0 samples/client/petstore/dart2/flutter_petstore/openapi/test/user_test.dart
  112. +1 −1 samples/client/petstore/dart2/openapi-browser-client/.openapi-generator/VERSION
  113. +11 −0 samples/client/petstore/dart2/openapi-browser-client/.travis.yml
  114. +3 −1 samples/client/petstore/dart2/openapi-browser-client/pubspec.yaml
  115. +27 −0 samples/client/petstore/dart2/openapi-browser-client/test/api_response_test.dart
  116. +22 −0 samples/client/petstore/dart2/openapi-browser-client/test/category_test.dart
  117. +43 −0 samples/client/petstore/dart2/openapi-browser-client/test/order_test.dart
  118. +73 −0 samples/client/petstore/dart2/openapi-browser-client/test/pet_api_test.dart
  119. +43 −0 samples/client/petstore/dart2/openapi-browser-client/test/pet_test.dart
  120. +45 −0 samples/client/petstore/dart2/openapi-browser-client/test/store_api_test.dart
  121. +22 −0 samples/client/petstore/dart2/openapi-browser-client/test/tag_test.dart
  122. +73 −0 samples/client/petstore/dart2/openapi-browser-client/test/user_api_test.dart
  123. +53 −0 samples/client/petstore/dart2/openapi-browser-client/test/user_test.dart
  124. +1 −1 samples/client/petstore/dart2/openapi/.openapi-generator/VERSION
  125. +11 −0 samples/client/petstore/dart2/openapi/.travis.yml
  126. +3 −1 samples/client/petstore/dart2/openapi/pubspec.yaml
  127. +27 −0 samples/client/petstore/dart2/openapi/test/api_response_test.dart
  128. +22 −0 samples/client/petstore/dart2/openapi/test/category_test.dart
  129. +43 −0 samples/client/petstore/dart2/openapi/test/order_test.dart
  130. +73 −0 samples/client/petstore/dart2/openapi/test/pet_api_test.dart
  131. +43 −0 samples/client/petstore/dart2/openapi/test/pet_test.dart
  132. +45 −0 samples/client/petstore/dart2/openapi/test/store_api_test.dart
  133. +22 −0 samples/client/petstore/dart2/openapi/test/tag_test.dart
  134. +73 −0 samples/client/petstore/dart2/openapi/test/user_api_test.dart
  135. +53 −0 samples/client/petstore/dart2/openapi/test/user_test.dart
  136. +6 −0 samples/client/petstore/dart2/purge_test.sh
@@ -221,6 +221,7 @@ samples/server/petstore/erlang-server/rebar.lock
samples/client/petstore/dart/petstore/packages
samples/client/petstore/dart/flutter_petstore/test/packages
samples/client/petstore/dart/petstore/test/packages
**/.dart_tool

# JS
samples/client/petstore/javascript/package-lock.json
@@ -49,6 +49,8 @@
protected String sourceFolder = "";
protected String apiDocPath = "docs" + File.separator;
protected String modelDocPath = "docs" + File.separator;
protected String apiTestPath = "test" + File.separator;
protected String modelTestPath = "test" + File.separator;

public DartClientCodegen() {
super();
@@ -66,6 +68,9 @@ public DartClientCodegen() {
modelDocTemplateFiles.put("object_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");

modelTestTemplateFiles.put("model_test.mustache", ".dart");
apiTestTemplateFiles.put("api_test.mustache", ".dart");

setReservedWordsLowerCase(
Arrays.asList(
"abstract", "as", "assert", "async", "async*", "await",
@@ -214,6 +219,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
}

@Override
@@ -231,6 +237,16 @@ public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}

@Override
public String apiTestFileFolder() {
return outputFolder + File.separator + apiTestPath.replace('/', File.separatorChar);
}

@Override
public String modelTestFileFolder() {
return outputFolder + File.separator + modelTestPath.replace('/', File.separatorChar);
}

@Override
public String apiDocFileFolder() {
return outputFolder + File.separator + apiDocPath.replace('/', File.separatorChar);
@@ -295,6 +311,16 @@ public String toApiFilename(String name) {
return underscore(toApiName(name));
}

@Override
public String toApiTestFilename(String name) {
return toApiFilename(name) + "_test";
}

@Override
public String toModelTestFilename(String name) {
return toModelFilename(name) + "_test";
}

@Override
public String toDefaultValue(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
@@ -177,6 +177,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));

final String authFolder = sourceFolder + File.separator + "lib" + File.separator + "auth";
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
@@ -0,0 +1,28 @@
import 'package:{{pubName}}/api.dart';
import 'package:test/test.dart';

{{#operations}}

/// tests for {{classname}}
void main() {
var instance = new {{classname}}();

group('tests for {{classname}}', () {
{{#operation}}
{{#summary}}
// {{{.}}}
//
{{/summary}}
{{#notes}}
// {{{.}}}
//
{{/notes}}
//{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
test('test {{operationId}}', () async {
// TODO
});

{{/operation}}
});
}
{{/operations}}
@@ -0,0 +1,26 @@
{{#models}}
{{#model}}
import 'package:{{pubName}}/api.dart';
import 'package:test/test.dart';

// tests for {{classname}}
void main() {
var instance = new Pet();

group('test {{classname}}', () {
{{#vars}}
{{#description}}
// {{{description}}}
{{/description}}
// {{{dataType}}} {{name}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
test('to test the property `{{name}}`', () async {
// TODO
});

{{/vars}}

});

}
{{/model}}
{{/models}}
@@ -0,0 +1,11 @@
# https://docs.travis-ci.com/user/languages/dart/
#
language: dart
dart:
# Install a specific stable release
- "1.24.3"
install:
- pub get

script:
- pub run test
@@ -0,0 +1,28 @@
import 'package:{{pubName}}/api.dart';
import 'package:test/test.dart';

{{#operations}}

/// tests for {{classname}}
void main() {
var instance = new {{classname}}();

group('tests for {{classname}}', () {
{{#operation}}
{{#summary}}
// {{{.}}}
//
{{/summary}}
{{#notes}}
// {{{.}}}
//
{{/notes}}
//{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
test('test {{operationId}}', () async {
// TODO
});

{{/operation}}
});
}
{{/operations}}
@@ -0,0 +1,26 @@
{{#models}}
{{#model}}
import 'package:{{pubName}}/api.dart';
import 'package:test/test.dart';

// tests for {{classname}}
void main() {
var instance = new Pet();

group('test {{classname}}', () {
{{#vars}}
{{#description}}
// {{{description}}}
{{/description}}
// {{{dataType}}} {{name}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
test('to test the property `{{name}}`', () async {
// TODO
});

{{/vars}}

});

}
{{/model}}
{{/models}}
@@ -3,3 +3,5 @@ version: {{pubVersion}}
description: {{pubDescription}}
dependencies:
http: '>=0.11.1 <0.13.0'
dev_dependencies:
test: ^1.3.0
@@ -0,0 +1,11 @@
# https://docs.travis-ci.com/user/languages/dart/
#
language: dart
dart:
# Install a specific stable release
- "1.24.3"
install:
- pub get

script:
- pub run test
@@ -0,0 +1,28 @@
import 'package:{{pubName}}/api.dart';
import 'package:test/test.dart';

{{#operations}}

/// tests for {{classname}}
void main() {
var instance = new {{classname}}();

group('tests for {{classname}}', () {
{{#operation}}
{{#summary}}
// {{{.}}}
//
{{/summary}}
{{#notes}}
// {{{.}}}
//
{{/notes}}
//{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
test('test {{operationId}}', () async {
// TODO
});

{{/operation}}
});
}
{{/operations}}
@@ -0,0 +1,26 @@
{{#models}}
{{#model}}
import 'package:{{pubName}}/api.dart';
import 'package:test/test.dart';

// tests for {{classname}}
void main() {
var instance = new Pet();

group('test {{classname}}', () {
{{#vars}}
{{#description}}
// {{{description}}}
{{/description}}
// {{{dataType}}} {{name}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
test('to test the property `{{name}}`', () async {
// TODO
});

{{/vars}}

});

}
{{/model}}
{{/models}}
@@ -5,3 +5,5 @@ environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
http: '>=0.11.1 <0.13.0'
dev_dependencies:
test: ^1.3.0
@@ -0,0 +1,11 @@
# https://docs.travis-ci.com/user/languages/dart/
#
language: dart
dart:
# Install a specific stable release
- "2.2.0"
install:
- pub get

script:
- pub run test
@@ -1 +1 @@
4.0.0-SNAPSHOT
4.0.1-SNAPSHOT
@@ -0,0 +1,11 @@
# https://docs.travis-ci.com/user/languages/dart/
#
language: dart
dart:
# Install a specific stable release
- "1.24.3"
install:
- pub get

script:
- pub run test
@@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:

- API version: 1.0.0
- Build date: 2019-03-01T12:01:27.554664+01:00[Europe/Paris]
- Build date: 2019-05-27T15:39:26.158+08:00[Asia/Hong_Kong]
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen

## Requirements
@@ -0,0 +1,27 @@
import 'package:openapi/api.dart';
import 'package:test/test.dart';

// tests for ApiResponse
void main() {
var instance = new Pet();

group('test ApiResponse', () {
// int code (default value: null)
test('to test the property `code`', () async {
// TODO
});

// String type (default value: null)
test('to test the property `type`', () async {
// TODO
});

// String message (default value: null)
test('to test the property `message`', () async {
// TODO
});


});

}
@@ -0,0 +1,22 @@
import 'package:openapi/api.dart';
import 'package:test/test.dart';

// tests for Category
void main() {
var instance = new Pet();

group('test Category', () {
// int id (default value: null)
test('to test the property `id`', () async {
// TODO
});

// String name (default value: null)
test('to test the property `name`', () async {
// TODO
});


});

}

0 comments on commit b88b1d6

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