Skip to content

Commit 20a2d17

Browse files
author
Bastian Wilhelm
committed
#34 fix unit tests
1 parent 3a58acb commit 20a2d17

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/main/groovy/com/github/hauner/openapi/spring/writer/MethodWriter.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,24 @@ class MethodWriter {
109109

110110
if (it.withAnnotation ()) {
111111
if(apiOptions.beanValidation){
112-
methodDefinition += " ${beanValidationWriter.createAnnotations(it.dataType)} "
112+
methodDefinition += " ${beanValidationWriter.createAnnotations(it.dataType)}"
113113
}
114114

115-
methodDefinition += " ${createParameterAnnotation (it)} "
115+
methodDefinition += " ${createParameterAnnotation (it)}"
116116
}
117117

118-
methodDefinition += " ${it.dataType.name} ${Identifier.toCamelCase (it.name)} "
119-
methodDefinition
118+
methodDefinition += " ${it.dataType.name} ${Identifier.toCamelCase (it.name)}"
119+
methodDefinition.trim()
120120
}
121121

122122
if (!endpoint.requestBodies.empty) {
123123
def body = endpoint.requestBody
124124
def beanValidationAnnotations = ''
125125
if(apiOptions.beanValidation){
126-
beanValidationAnnotations += " ${beanValidationWriter.createAnnotations(body.requestBodyType)} "
126+
beanValidationAnnotations += " ${beanValidationWriter.createAnnotations(body.requestBodyType)}"
127127
}
128128
def param = "${beanValidationAnnotations} ${createRequestBodyAnnotation(body)} ${body.requestBodyType.name} body"
129-
ps.add (param)
129+
ps.add (param.trim())
130130
}
131131

132132
ps.join (', ')

src/test/groovy/com/github/hauner/openapi/spring/writer/InterfaceWriterSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.github.hauner.openapi.spring.writer
1818

19+
import com.github.hauner.openapi.spring.converter.ApiOptions
1920
import com.github.hauner.openapi.spring.model.Endpoint
2021
import com.github.hauner.openapi.spring.model.HttpMethod
2122
import com.github.hauner.openapi.spring.model.Interface
@@ -37,8 +38,9 @@ import static com.github.hauner.openapi.spring.support.AssertHelper.extractImpor
3738
class InterfaceWriterSpec extends Specification {
3839
def headerWriter = Mock HeaderWriter
3940
def methodWriter = Stub MethodWriter
41+
def apiOptions = new ApiOptions()
4042

41-
def writer = new InterfaceWriter(headerWriter: headerWriter, methodWriter: methodWriter)
43+
def writer = new InterfaceWriter(headerWriter: headerWriter, methodWriter: methodWriter, apiOptions: apiOptions)
4244
def target = new StringWriter ()
4345

4446
void "writes 'generated' comment" () {

src/test/groovy/com/github/hauner/openapi/spring/writer/MethodWriterSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.github.hauner.openapi.spring.writer
1818

19+
import com.github.hauner.openapi.spring.converter.ApiOptions
1920
import com.github.hauner.openapi.spring.model.Endpoint
2021
import com.github.hauner.openapi.spring.model.HttpMethod
2122
import com.github.hauner.openapi.spring.model.RequestBody
@@ -40,7 +41,8 @@ import spock.lang.Specification
4041
import spock.lang.Unroll
4142

4243
class MethodWriterSpec extends Specification {
43-
def writer = new MethodWriter ()
44+
def apiOptions = new ApiOptions()
45+
def writer = new MethodWriter (apiOptions: apiOptions)
4446
def target = new StringWriter ()
4547

4648
void "writes parameter less method without response" () {

0 commit comments

Comments
 (0)