Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Mar 12, 2014
1 parent f43977e commit d4d08c3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package converter

import converter.models._

import com.wordnik.swagger.converter._
import com.wordnik.swagger.model._

import com.wordnik.swagger.annotations._
import com.wordnik.swagger.converter._
import com.wordnik.swagger.core.util._
import com.wordnik.swagger.model._

import scala.reflect.BeanProperty
import scala.collection.mutable.LinkedHashMap

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers

import javax.xml.bind.annotation._

@RunWith(classOf[JUnitRunner])
class PropertyAnnotationTest extends FlatSpec with ShouldMatchers {
it should "read annotations on a property" in {
val a = ModelConverters.readAll(classOf[ModelWithAnnotationOnProperty])
JsonSerializer.asJson(a) should be ("""[{"id":"ModelWithAnnotationOnProperty","description":"my annotated model","properties":{"count":{"type":"integer","format":"int32","description":"the count of items"}}}]""")

/*
[
{
"id": "ModelWithAnnotationOnProperty",
"description": "my annotated model",
"properties": {
"count": {
"type": "integer",
"format": "int32",
"description": "the count of items"
}
}
}
]
*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package converter.models;

import com.wordnik.swagger.annotations.*;

@ApiModel(description = "my annotated model")
public class ModelWithAnnotationOnProperty {
@ApiModelProperty(value = "the count of items", position = 1)
private Integer count;

public void setCount(Integer count) {
this.count = count;
}

public Integer getCount() {
return count;
}
}

0 comments on commit d4d08c3

Please sign in to comment.