mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Merge pull request #679 from xhh/petstore-scala-tests
Fix tests for Scala petstore sample
This commit is contained in:
commit
08184aab1d
13
pom.xml
13
pom.xml
@ -302,6 +302,18 @@
|
|||||||
<module>samples/client/petstore/java</module>
|
<module>samples/client/petstore/java</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>scala-client</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>scala</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/client/petstore/scala</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>objc-client</id>
|
<id>objc-client</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -361,6 +373,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>samples/client/petstore/android-java</module>
|
<module>samples/client/petstore/android-java</module>
|
||||||
<module>samples/client/petstore/java</module>
|
<module>samples/client/petstore/java</module>
|
||||||
|
<module>samples/client/petstore/scala</module>
|
||||||
<module>samples/server/petstore/jaxrs</module>
|
<module>samples/server/petstore/jaxrs</module>
|
||||||
<module>samples/server/petstore/spring-mvc</module>
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
<module>samples/client/petstore/objc</module>
|
<module>samples/client/petstore/objc</module>
|
||||||
|
@ -15,17 +15,7 @@ class PetApiTest extends FlatSpec with Matchers {
|
|||||||
behavior of "PetApi"
|
behavior of "PetApi"
|
||||||
val api = new PetApi
|
val api = new PetApi
|
||||||
|
|
||||||
it should "fetch a pet" in {
|
it should "add and fetch a pet" in {
|
||||||
api.getPetById(1) match {
|
|
||||||
case Some(pet) => {
|
|
||||||
pet should not be (null)
|
|
||||||
pet.id should be(1)
|
|
||||||
}
|
|
||||||
case None => fail("didn't find pet 1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
it should "add a new pet" in {
|
|
||||||
val pet = Pet(
|
val pet = Pet(
|
||||||
1000,
|
1000,
|
||||||
Category(1, "sold"),
|
Category(1, "sold"),
|
||||||
|
@ -17,19 +17,7 @@ class StoreApiTest extends FlatSpec with Matchers {
|
|||||||
|
|
||||||
api.apiInvoker.defaultHeaders += "api_key" -> "special-key"
|
api.apiInvoker.defaultHeaders += "api_key" -> "special-key"
|
||||||
|
|
||||||
it should "fetch an order" in {
|
it should "place and fetch an order" in {
|
||||||
api.getOrderById("1") match {
|
|
||||||
case Some(order) => {
|
|
||||||
order.id should be(1)
|
|
||||||
order.petId should be(1)
|
|
||||||
order.quantity should be(2)
|
|
||||||
order.shipDate should not be (null)
|
|
||||||
}
|
|
||||||
case None => fail("didn't find order")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
it should "place an order" in {
|
|
||||||
val now = new org.joda.time.DateTime
|
val now = new org.joda.time.DateTime
|
||||||
val order = Order (
|
val order = Order (
|
||||||
petId = 10,
|
petId = 10,
|
||||||
@ -46,9 +34,10 @@ class StoreApiTest extends FlatSpec with Matchers {
|
|||||||
order.id should be(1000)
|
order.id should be(1000)
|
||||||
order.petId should be(10)
|
order.petId should be(10)
|
||||||
order.quantity should be(101)
|
order.quantity should be(101)
|
||||||
order.shipDate.equals(now) should be (true)
|
// use `getMillis` to compare across timezones
|
||||||
|
order.shipDate.getMillis.equals(now.getMillis) should be (true)
|
||||||
}
|
}
|
||||||
case None =>
|
case None => fail("didn't find order created")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +54,14 @@ class StoreApiTest extends FlatSpec with Matchers {
|
|||||||
api.placeOrder(order)
|
api.placeOrder(order)
|
||||||
|
|
||||||
api.getOrderById("1001") match {
|
api.getOrderById("1001") match {
|
||||||
case Some(order) => {
|
case Some(order) => order.id should be(1001)
|
||||||
order.id should be(1001)
|
case None => fail("didn't find order created")
|
||||||
order.petId should be(10)
|
}
|
||||||
order.quantity should be(101)
|
|
||||||
order.shipDate.equals(now) should be (true)
|
api.deleteOrder("1001")
|
||||||
}
|
api.getOrderById("1001") match {
|
||||||
|
case Some(order) => fail("order should have been deleted")
|
||||||
case None =>
|
case None =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user