Skip to content

Commit 1dfe86e

Browse files
committed
Update ModelPropertyParserTest.scala
1 parent b9da4b7 commit 1dfe86e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/test/scala/com/github/swagger/enumeratum/converter/ModelPropertyParserTest.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
2828
model.get.getProperties should not be (null)
2929
val field = model.value.getProperties.get("field")
3030
field shouldBe a[StringSchema]
31-
field.asInstanceOf[StringSchema].getEnum.asScala shouldEqual OrderSize.values.map(_.entryName)
31+
nullSafeList(field.asInstanceOf[StringSchema].getEnum) shouldEqual OrderSize.values.map(_.entryName)
3232
nullSafeList(model.value.getRequired) shouldBe Seq("field")
3333
}
3434
it should "process Model with Optional Enumeratum Enum" in {
@@ -39,7 +39,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
3939
model.get.getProperties should not be (null)
4040
val field = model.value.getProperties.get("field")
4141
field shouldBe a[StringSchema]
42-
field.asInstanceOf[StringSchema].getEnum.asScala shouldEqual OrderSize.values.map(_.entryName)
42+
nullSafeList(field.asInstanceOf[StringSchema].getEnum) shouldEqual OrderSize.values.map(_.entryName)
4343
nullSafeList(model.value.getRequired) shouldBe empty
4444
}
4545
it should "process Model with Enumeratum Set" in {
@@ -51,7 +51,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
5151
val field = model.value.getProperties.get("sizes")
5252
field shouldBe a[ArraySchema]
5353
val arraySchema = field.asInstanceOf[ArraySchema]
54-
arraySchema.getItems.getEnum.asScala shouldEqual OrderSize.values.map(_.entryName)
54+
nullSafeList(arraySchema.getItems.getEnum) shouldEqual OrderSize.values.map(_.entryName)
5555
nullSafeList(model.value.getRequired) shouldEqual List("sizes")
5656
}
5757
it should "process Model with Annotated Enumeratum Enum" in {
@@ -64,7 +64,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
6464
field shouldBe a[StringSchema]
6565
val schema = field.asInstanceOf[StringSchema]
6666
schema.getDescription shouldEqual "enum value"
67-
schema.getEnum.asScala shouldEqual OrderSize.values.map(_.entryName)
67+
nullSafeList(schema.getEnum) shouldEqual OrderSize.values.map(_.entryName)
6868
nullSafeList(model.value.getRequired) shouldBe Seq.empty
6969
}
7070
it should "process Model for Enumeratum Enum defined in scope of another object" in {
@@ -82,7 +82,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
8282
val schema = field.asInstanceOf[StringSchema]
8383
schema.getDescription shouldEqual (null)
8484
schema.getDefault should be(null)
85-
schema.getEnum.asScala shouldEqual Ctx.Color.values.map(_.entryName)
85+
nullSafeList(schema.getEnum) shouldEqual Ctx.Color.values.map(_.entryName)
8686
nullSafeList(model.value.getRequired) shouldBe Seq("field")
8787
}
8888

@@ -96,14 +96,14 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
9696
catProps.get("name") shouldBe a[StringSchema]
9797
catProps.get("age") shouldBe a[IntegerSchema]
9898
catProps.get("animalType") shouldBe a[StringSchema]
99-
catModel.value.getRequired.asScala shouldEqual Seq("age", "animalType", "name")
99+
nullSafeList(catModel.value.getRequired) shouldEqual Seq("age", "animalType", "name")
100100
val dogModel = findModel(schemas, "Dog")
101101
dogModel should be(defined)
102102
val dogProps = dogModel.value.getProperties
103103
dogProps should have size 2
104104
dogProps.get("name") shouldBe a[StringSchema]
105105
dogProps.get("animalType") shouldBe a[StringSchema]
106-
dogModel.value.getRequired.asScala shouldEqual Seq("animalType", "name")
106+
nullSafeList(dogModel.value.getRequired) shouldEqual Seq("animalType", "name")
107107
}
108108

109109
it should "not add additional model when enum field is annotated" in {
@@ -121,7 +121,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
121121
schema.getName shouldEqual "field"
122122
schema.getDefault should be(null)
123123
schema.getDeprecated should be(null)
124-
schema.getEnum.asScala shouldEqual Ctx.Color.values.map(_.entryName)
124+
nullSafeList(schema.getEnum) shouldEqual Ctx.Color.values.map(_.entryName)
125125
nullSafeList(model.value.getRequired) shouldBe Seq("field")
126126
}
127127

0 commit comments

Comments
 (0)