@@ -24,6 +24,7 @@ import org.scalatest.FlatSpec
24
24
import org .scalatest .Matchers
25
25
26
26
import scala .beans .BeanProperty
27
+ import scala .collection .mutable .{ HashMap , LinkedHashMap }
27
28
28
29
@ RunWith (classOf [JUnitRunner ])
29
30
class CodegenTest extends FlatSpec with Matchers {
@@ -40,8 +41,18 @@ class CodegenTest extends FlatSpec with Matchers {
40
41
List .empty,
41
42
List .empty,
42
43
List .empty,
44
+ // query param
45
+ List (new Parameter (" Name" , Some (" name" ), Some (" null" ), false , false , " String" , AnyAllowableValues , " query" , None )),
43
46
List .empty,
44
- List .empty,
47
+ None )
48
+
49
+ val testModel = new Model (" Contact" ,
50
+ " Contact" ,
51
+ " Contact" ,
52
+ // required field
53
+ LinkedHashMap (" Name" -> new ModelProperty (" String" , " String" , 0 , true , None , AnyAllowableValues , None )),
54
+ None ,
55
+ None ,
45
56
None )
46
57
47
58
behavior of " Codegen"
@@ -52,4 +63,21 @@ class CodegenTest extends FlatSpec with Matchers {
52
63
val map = subject.apiToMap(" /contacts" , testOp)
53
64
map(" returnContainer" ) should be (Some (" List" ))
54
65
}
66
+
67
+ /*
68
+ * Field first on the query param should be true
69
+ */
70
+ it should " have a first field on first query param and should be true" in {
71
+ val map = subject.apiToMap(" /contacts" , testOp)
72
+ map(" queryParams" ).asInstanceOf [List [HashMap [String , String ]]].head(" first" ) should be (" true" )
73
+ }
74
+
75
+ /*
76
+ * Field hasRequiredParams should be true
77
+ */
78
+ it should " have a hasRequiredParams field and should be true" in {
79
+ val map = subject.modelToMap(" Contact" , testModel)
80
+ map(" hasRequiredParams" ) should be (" true" )
81
+ }
55
82
}
83
+
0 commit comments