@@ -7,8 +7,8 @@ package io.openapiprocessor.core.writer.java
77
88import io.openapiprocessor.core.converter.ApiOptions
99import io.openapiprocessor.core.model.Documentation
10+ import io.openapiprocessor.core.model.datatypes.DataTypeName
1011import io.openapiprocessor.core.model.datatypes.StringEnumDataType
11- import io.openapiprocessor.core.support.datatypes.DataTypeName
1212import spock.lang.Specification
1313
1414class StringEnumWriterSpec extends Specification {
@@ -19,10 +19,18 @@ class StringEnumWriterSpec extends Specification {
1919 def writer = new StringEnumWriter (options, identifier, generatedWriter, javadocWriter)
2020 def target = new StringWriter ()
2121
22+ private DataTypeName dataTypeName (String id ) {
23+ return new DataTypeName (id, id)
24+ }
25+
26+ private DataTypeName dataTypeName (String id , String type ) {
27+ return new DataTypeName (id, type)
28+ }
29+
2230 void " writes 'package'" () {
2331 def pkg = ' com.github.hauner.openapi'
2432 def dataType = new StringEnumDataType (
25- new DataTypeName (' Foo' ), pkg, [], null , false , null )
33+ dataTypeName (' Foo' ), pkg, [], null , false , null )
2634
2735 when :
2836 writer. write (target, dataType)
@@ -36,7 +44,7 @@ package $pkg;
3644
3745 void " writes javadoc comment" () {
3846 def dataType = new StringEnumDataType (
39- new DataTypeName (' Foo' ), ' pkg' , [], null , false ,
47+ dataTypeName (' Foo' ), ' pkg' , [], null , false ,
4048 new Documentation (null , " description" ))
4149
4250 when :
@@ -53,7 +61,7 @@ package $pkg;
5361
5462 void " writes @Generated import" () {
5563 def dataType = new StringEnumDataType (
56- new DataTypeName (' Foo' ), ' pkg' , [], null , false , null )
64+ dataTypeName (' Foo' ), ' pkg' , [], null , false , null )
5765
5866 when :
5967 writer. write (target, dataType)
@@ -67,7 +75,7 @@ import io.openapiprocessor.generated.support.Generated;
6775 void " writes enum class" () {
6876 def pkg = ' com.github.hauner.openapi'
6977 def dataType = new StringEnumDataType (
70- new DataTypeName (id, type), pkg, [], null , false , null )
78+ dataTypeName (id, type), pkg, [], null , false , null )
7179
7280 when :
7381 writer. write (target, dataType)
@@ -91,7 +99,7 @@ public enum $type {
9199 options. enumType = " framework"
92100
93101 def dataType = new StringEnumDataType (
94- new DataTypeName (' Foo' ), ' pkg' , [], null , false , null )
102+ dataTypeName (' Foo' ), ' pkg' , [], null , false , null )
95103
96104 when :
97105 writer. write (target, dataType)
@@ -107,7 +115,7 @@ import java.util.function.Supplier;
107115
108116 def pkg = ' com.github.hauner.openapi'
109117 def dataType = new StringEnumDataType (
110- new DataTypeName (id, type), pkg, [], null , false , null )
118+ dataTypeName (id, type), pkg, [], null , false , null )
111119
112120 when :
113121 writer. write (target, dataType)
@@ -130,7 +138,7 @@ public enum $type implements Supplier<String> {
130138 void " writes enum values" () {
131139 def pkg = ' com.github.hauner.openapi'
132140 def dataType = new StringEnumDataType (
133- new DataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
141+ dataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
134142
135143 when :
136144 writer. write (target, dataType)
@@ -148,7 +156,7 @@ public enum Foo {
148156 void " writes value member" () {
149157 def pkg = ' com.github.hauner.openapi'
150158 def dataType = new StringEnumDataType (
151- new DataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
159+ dataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
152160
153161 when :
154162 writer. write (target, dataType)
@@ -163,7 +171,7 @@ public enum Foo {
163171 void " writes enum constructor" () {
164172 def pkg = ' com.github.hauner.openapi'
165173 def dataType = new StringEnumDataType (
166- new DataTypeName (id, type), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
174+ dataTypeName (id, type), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
167175
168176 when :
169177 writer. write (target, dataType)
@@ -186,7 +194,7 @@ public enum Foo {
186194 void " writes @JsonValue method for serialization" () {
187195 def pkg = ' com.github.hauner.openapi'
188196 def dataType = new StringEnumDataType (
189- new DataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
197+ dataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
190198
191199 when :
192200 writer. write (target, dataType)
@@ -207,7 +215,7 @@ public enum Foo {
207215
208216 def pkg = ' com.github.hauner.openapi'
209217 def dataType = new StringEnumDataType (
210- new DataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
218+ dataTypeName (' Foo' ), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
211219
212220 when :
213221 writer. write (target, dataType)
@@ -226,7 +234,7 @@ public enum Foo {
226234 void " writes @JsonCreator method for de-serialization" () {
227235 def pkg = ' com.github.hauner.openapi'
228236 def dataType = new StringEnumDataType (
229- new DataTypeName (id, type), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
237+ dataTypeName (id, type), pkg, [' foo' , ' _foo-2' , ' foo-foo' ], null , false , null )
230238
231239 when :
232240 writer. write (target, dataType)
@@ -254,7 +262,7 @@ public enum Foo {
254262 void " writes jackson imports" () {
255263 def pkg = ' com.github.hauner.openapi'
256264 def dataType = new StringEnumDataType (
257- new DataTypeName (' Foo' ), pkg, [], null , false , null )
265+ dataTypeName (' Foo' ), pkg, [], null , false , null )
258266
259267 when :
260268 writer. write (target, dataType)
@@ -265,8 +273,4 @@ import com.fasterxml.jackson.annotation.JsonCreator;
265273import com.fasterxml.jackson.annotation.JsonValue;
266274""" )
267275 }
268-
269276}
270-
271-
272-
0 commit comments