update kotlin auto-generated test to avoid npe (#10058)

This commit is contained in:
William Cheng 2021-08-02 18:44:03 +08:00 committed by GitHub
parent ec49dc3fed
commit 594d08a7a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,6 @@ package {{package}}
{{#imports}}import {{import}} {{#imports}}import {{import}}
{{/imports}} {{/imports}}
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
{{#reactive}} {{#reactive}}
import kotlinx.coroutines.flow.Flow; import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.test.runBlockingTest import kotlinx.coroutines.test.runBlockingTest
@ -12,14 +11,15 @@ import org.springframework.http.ResponseEntity
class {{classname}}Test { class {{classname}}Test {
{{#serviceInterface}}private val service: {{classname}}Service = {{classname}}ServiceImpl(){{/serviceInterface}} {{#serviceInterface}}
private val service: {{classname}}Service = {{classname}}ServiceImpl()
{{/serviceInterface}}
private val api: {{classname}}Controller = {{classname}}Controller({{#serviceInterface}}service{{/serviceInterface}}) private val api: {{classname}}Controller = {{classname}}Controller({{#serviceInterface}}service{{/serviceInterface}})
{{#operations}}{{#operation}} {{#operations}}
{{#operation}}
/** /**
* {{summary}} * To test {{classname}}Controller.{{operationId}}
*
* {{notes}}
* *
* @throws ApiException * @throws ApiException
* if the Api call fails * if the Api call fails
@ -29,9 +29,11 @@ class {{classname}}Test {
{{#allParams}} {{#allParams}}
val {{paramName}}:{{{dataType}}}? = null val {{paramName}}:{{{dataType}}}? = null
{{/allParams}} {{/allParams}}
val response: ResponseEntity<{{>returnTypes}}> = api.{{operationId}}({{#allParams}}{{paramName}}!!{{^-last}}, {{/-last}}{{/allParams}}) val response: ResponseEntity<{{>returnTypes}}> = api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
// TODO: test validations // TODO: test validations
} }
{{/operation}}{{/operations}}
{{/operation}}
{{/operations}}
} }