Skip to content

Commit 1e6f954

Browse files
author
gbolt
committed
gbolt - Added ModelUtilTest to establish current behavior for cleanDataType
1 parent 2b129f1 commit 1e6f954

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

modules/swagger-core/src/test/scala/converter/ModelUtilTest.scala

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,34 @@ import org.scalatest.Matchers
88
@RunWith(classOf[JUnitRunner])
99
class ModelUtilTest extends FlatSpec with Matchers {
1010
import com.wordnik.swagger.core.util.ModelUtil._
11-
"ModelUtil cleanDataType" should "strip the package from a class name" in {
11+
12+
"ModelUtil cleanDataType" should "convert a fully-qualified primitive type to a SwaggerTypes primitive" in {
13+
val primitiveName = "java.lang.Integer"
14+
val cleanName = cleanDataType(primitiveName)
15+
cleanName should equal ("int")
16+
}
17+
18+
it should "convert a primitive type simple name to a SwaggerTypes primitive" in {
19+
val primitiveName = "Integer"
20+
val cleanName = cleanDataType(primitiveName)
21+
cleanName should equal ("int")
22+
}
23+
24+
it should "convert the inner class of a container to a SwaggerTypes primitive" in {
25+
val origName = "List[java.lang.Integer]"
26+
val cleanName = cleanDataType(origName)
27+
cleanName should equal ("List[int]")
28+
}
29+
30+
it should "return a fully-qualified class name unchanged" in {
1231
val fqcn = "com.wordnik.swagger.core.ModelUtil"
1332
val cleanName = cleanDataType(fqcn)
1433
cleanName should equal (fqcn)
1534
}
35+
36+
it should "return a container with a fully-qualified inner class name unchanged" in {
37+
val fqcn = "List[com.wordnik.swagger.core.ModelUtil]"
38+
val cleanName = cleanDataType(fqcn)
39+
cleanName should equal (fqcn)
40+
}
1641
}

0 commit comments

Comments
 (0)