-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
modules/swagger-core/src/test/scala/converter/XMLGregorianCalendarTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package converter | ||
|
||
import model._ | ||
|
||
import com.wordnik.swagger.annotations._ | ||
import com.wordnik.swagger.converter._ | ||
import com.wordnik.swagger.core.util._ | ||
import com.wordnik.swagger.model._ | ||
|
||
import org.joda.time.DateTime | ||
|
||
import scala.collection.mutable.LinkedHashMap | ||
import scala.annotation.target.field | ||
import javax.xml.datatype.XMLGregorianCalendar | ||
|
||
import org.junit.runner.RunWith | ||
import org.scalatest.junit.JUnitRunner | ||
import org.scalatest.FlatSpec | ||
import org.scalatest.matchers.ShouldMatchers | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class XMLGregorianCalendarTest extends FlatSpec with ShouldMatchers { | ||
it should "read a model with XMLGregorianCalendar" in { | ||
val models = ModelConverters.readAll(classOf[ModelWithCalendar]) | ||
models.size should be (1) // don't create a Joda DateTime object | ||
|
||
val model = models.head | ||
val nameProperty = model.properties("name") | ||
nameProperty.`type` should be ("string") | ||
nameProperty.position should be (2) | ||
nameProperty.description should be (Some("name of the model")) | ||
|
||
val dateTimeProperty = model.properties("createdAt") | ||
dateTimeProperty.`type` should be ("Date") | ||
dateTimeProperty.position should be (1) | ||
dateTimeProperty.required should be (true) | ||
dateTimeProperty.description should be (Some("creation timestamp")) | ||
|
||
println(JsonSerializer.asJson(models.head)) | ||
} | ||
} | ||
|
||
|
||
case class ModelWithCalendar ( | ||
@(ApiModelProperty @field)(value = "name of the model", position = 2) name: String, | ||
@(ApiModelProperty @field)(value = "creation timestamp", required = true, position = 1) createdAt: XMLGregorianCalendar) |