mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +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>
|
||||
</modules>
|
||||
</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>
|
||||
<id>objc-client</id>
|
||||
<activation>
|
||||
@ -361,6 +373,7 @@
|
||||
<modules>
|
||||
<module>samples/client/petstore/android-java</module>
|
||||
<module>samples/client/petstore/java</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/server/petstore/jaxrs</module>
|
||||
<module>samples/server/petstore/spring-mvc</module>
|
||||
<module>samples/client/petstore/objc</module>
|
||||
|
@ -15,17 +15,7 @@ class PetApiTest extends FlatSpec with Matchers {
|
||||
behavior of "PetApi"
|
||||
val api = new PetApi
|
||||
|
||||
it should "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 {
|
||||
it should "add and fetch a pet" in {
|
||||
val pet = Pet(
|
||||
1000,
|
||||
Category(1, "sold"),
|
||||
|
@ -17,19 +17,7 @@ class StoreApiTest extends FlatSpec with Matchers {
|
||||
|
||||
api.apiInvoker.defaultHeaders += "api_key" -> "special-key"
|
||||
|
||||
it should "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 {
|
||||
it should "place and fetch an order" in {
|
||||
val now = new org.joda.time.DateTime
|
||||
val order = Order (
|
||||
petId = 10,
|
||||
@ -46,9 +34,10 @@ class StoreApiTest extends FlatSpec with Matchers {
|
||||
order.id should be(1000)
|
||||
order.petId should be(10)
|
||||
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.getOrderById("1001") match {
|
||||
case Some(order) => {
|
||||
order.id should be(1001)
|
||||
order.petId should be(10)
|
||||
order.quantity should be(101)
|
||||
order.shipDate.equals(now) should be (true)
|
||||
}
|
||||
case Some(order) => order.id should be(1001)
|
||||
case None => fail("didn't find order created")
|
||||
}
|
||||
|
||||
api.deleteOrder("1001")
|
||||
api.getOrderById("1001") match {
|
||||
case Some(order) => fail("order should have been deleted")
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user