forked from loafle/openapi-generator-original
update kotlin auto-generated test to avoid npe (#10058)
This commit is contained in:
parent
ec49dc3fed
commit
594d08a7a4
@ -3,7 +3,6 @@ package {{package}}
|
||||
{{#imports}}import {{import}}
|
||||
{{/imports}}
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
{{#reactive}}
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import kotlinx.coroutines.test.runBlockingTest
|
||||
@ -12,26 +11,29 @@ import org.springframework.http.ResponseEntity
|
||||
|
||||
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}})
|
||||
|
||||
{{#operations}}{{#operation}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{summary}}
|
||||
*
|
||||
* {{notes}}
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
* To test {{classname}}Controller.{{operationId}}
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun {{operationId}}Test() {{#reactive}}= runBlockingTest {{/reactive}}{
|
||||
{{#allParams}}
|
||||
val {{paramName}}:{{{dataType}}}? = null
|
||||
{{/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
|
||||
}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user