forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test templates for CXF swagger-api#2017
- Loading branch information
Showing
7 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{{>licenseInfo}} | ||
|
||
package {{package}}; | ||
|
||
{{#imports}}import {{import}}; | ||
{{/imports}} | ||
import org.junit.Test; | ||
import org.junit.Before; | ||
|
||
import javax.ws.rs.core.Response; | ||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory; | ||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; | ||
|
||
|
||
{{^fullJavaUtil}} | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
{{/fullJavaUtil}} | ||
|
||
/** | ||
* API tests for {{classname}} | ||
*/ | ||
public class {{classname}}Test { | ||
private {{classname}} api; | ||
|
||
@Before | ||
public void setup() { | ||
JacksonJsonProvider provider = new JacksonJsonProvider(); | ||
List providers = new ArrayList(); | ||
providers.add(provider); | ||
api = JAXRSClientFactory.create("{{basePath}}", {{classname}}.class, providers); | ||
} | ||
|
||
{{#operations}}{{#operation}} | ||
/** | ||
* {{summary}} | ||
* | ||
* {{notes}} | ||
* | ||
* @throws ApiException | ||
* if the Api call fails | ||
*/ | ||
@Test | ||
public void {{operationId}}Test() { | ||
{{#allParams}} | ||
{{{dataType}}} {{paramName}} = new {{{dataType}}}(); | ||
{{/allParams}} | ||
Response response = api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); | ||
|
||
{{#returnType}}{{{returnType}}} responseModel = response.readEntity({{{returnType}}}.class);{{/returnType}} | ||
|
||
// TODO: test validations | ||
} | ||
{{/operation}}{{/operations}} | ||
} |
23 changes: 23 additions & 0 deletions
23
modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/licenseInfo.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* {{{appName}}} | ||
* {{{appDescription}}} | ||
* | ||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}} | ||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters