From 296a45c8826a62298164ec9c99b3bfcb47787bea Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 5 Sep 2020 00:31:43 +0200 Subject: [PATCH 1/2] wip --- src/test/scala/ModelPropertyParserTest.scala | 13 +++++++++++++ src/test/scala/models/EchoList.scala | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 src/test/scala/models/EchoList.scala diff --git a/src/test/scala/ModelPropertyParserTest.scala b/src/test/scala/ModelPropertyParserTest.scala index dd6539d6..47f7febd 100644 --- a/src/test/scala/ModelPropertyParserTest.scala +++ b/src/test/scala/ModelPropertyParserTest.scala @@ -260,6 +260,19 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue mapSchema.getAdditionalProperties shouldBe a[StringProperty] } + it should "process EchoList" in { + val converter = ModelConverters.getInstance() + val schemas = converter.readAll(classOf[EchoList]).asScala.toMap + val model = findModel(schemas, "EchoList") + model should be (defined) + model.value.getProperties should not be (null) + val val1Field = model.value.getProperties.get("val1") + val1Field shouldBe a [StringProperty] + val val1Schema = val1Field.asInstanceOf[StringProperty] + val1Schema.getRequired shouldBe true + } + + private def findModel(schemas: Map[String, Model], name: String): Option[Model] = { schemas.get(name) match { case Some(m) => Some(m) diff --git a/src/test/scala/models/EchoList.scala b/src/test/scala/models/EchoList.scala new file mode 100644 index 00000000..a22a7110 --- /dev/null +++ b/src/test/scala/models/EchoList.scala @@ -0,0 +1,3 @@ +package models + +case class EchoList(val1: Int, val2: Int, val3: Int) From c670069a8ee88fe7ac359cdc0e241800754b500f Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 5 Sep 2020 00:35:28 +0200 Subject: [PATCH 2/2] add test case --- src/test/scala/ModelPropertyParserTest.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/scala/ModelPropertyParserTest.scala b/src/test/scala/ModelPropertyParserTest.scala index 47f7febd..256eb6f3 100644 --- a/src/test/scala/ModelPropertyParserTest.scala +++ b/src/test/scala/ModelPropertyParserTest.scala @@ -267,9 +267,13 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue model should be (defined) model.value.getProperties should not be (null) val val1Field = model.value.getProperties.get("val1") - val1Field shouldBe a [StringProperty] - val val1Schema = val1Field.asInstanceOf[StringProperty] + val1Field shouldBe a [IntegerProperty] + val val1Schema = val1Field.asInstanceOf[IntegerProperty] val1Schema.getRequired shouldBe true + val val2Field = model.value.getProperties.get("val2") + val2Field shouldBe a [IntegerProperty] + val val2Schema = val2Field.asInstanceOf[IntegerProperty] + val2Schema.getRequired shouldBe true }