Permalink
Browse files

added test for Map and Option[Map]

  • Loading branch information...
1 parent 1b0b635 commit c7f482b79083e2a0d935e557f93d5daf07581e89 Gregg committed Sep 24, 2012
View
19 modules/swagger-core/src/test/scala/com/wordnik/test/swagger/core/SpecReaderTest.scala
@@ -67,6 +67,16 @@ class SpecReaderTest extends FlatSpec with ShouldMatchers {
assert(docObj.getFields.filter(f => f.name == "setofLists").get(0).getParamType() === "Set[List[string]]")
}
+ it should "read an object with a Scala Map" in {
+ var docObj = ApiPropertiesReader.read(classOf[TestClassWithScalaMapandOptionOfMap])
+ assert(docObj.getFields.filter(_.name == "scalaMap").size > 0)
+ }
+
+ it should "read an object with an Option of Scala Map" in {
+ var docObj = ApiPropertiesReader.read(classOf[TestClassWithScalaMapandOptionOfMap])
+ assert(docObj.getFields.filter(_.name == "scalaMapOption").size > 0)
+ }
+
it should "read scala enum properties as string" in {
var docObj = ApiPropertiesReader.read(classOf[TestClassWithScalaEnums])
assert(docObj.getFields.filter(f => f.name == "label").get(0).getParamType() === "String")
@@ -411,6 +421,13 @@ class TestCollectionOfCollections {
//@XmlElement @BeanProperty var arrayofLists: Array[java.util.List[String]] = _
}
+@XmlRootElement(name = "TestClassWithScalaMapandOptionOfMap")
+@XmlAccessorType(XmlAccessType.NONE)
+class TestClassWithScalaMapandOptionOfMap {
+ @XmlElement @BeanProperty var scalaMap: scala.collection.immutable.Map[String, Double] = _
+ @XmlElement @BeanProperty var scalaMapOption: Option[scala.collection.immutable.Map[String, Double]] = _
+}
+
@XmlRootElement(name = "TestClassWithScalaEnums")
class TestClassWithScalaEnums {
@ApiProperty(dataType = "String") @XmlElement @BeanProperty var label: ScalaEnums.Value = _
@@ -489,4 +506,4 @@ object TestCompanionObject {
def getDescription():ObjectWithRootElementName = {
null
}
-}
+}

0 comments on commit c7f482b

Please sign in to comment.