forked from loafle/openapi-generator-original
[KOTLIN Client] Update to latest kotlin version (#2375)
* [KOTLIN Client] Update to latest kotlin version gradle - okhttp3 - kotlintest version update add some test case in sample * [KOTLIN Client] Update to latest kotlin version gradle - okhttp3 - kotlintest version update add some test case in sample
This commit is contained in:
parent
8bb01ed149
commit
37c275b3fb
@ -2,8 +2,8 @@
|
||||
|
||||
## Requires
|
||||
|
||||
* Kotlin 1.1.2
|
||||
* Gradle 3.3
|
||||
* Kotlin 1.3.20
|
||||
* Gradle 4.9
|
||||
|
||||
## Build
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
group '{{groupId}}'
|
||||
version '{{artifactVersion}}'
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '3.3'
|
||||
wrapper {
|
||||
gradleVersion = '4.9'
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.2'
|
||||
ext.kotlin_version = '1.3.20'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -23,11 +23,16 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
compile "com.squareup.moshi:moshi-kotlin:1.5.0"
|
||||
compile "com.squareup.moshi:moshi-adapters:1.5.0"
|
||||
compile "com.squareup.okhttp3:okhttp:3.8.0"
|
||||
compile "org.threeten:threetenbp:1.3.6"
|
||||
testCompile "io.kotlintest:kotlintest:2.0.2"
|
||||
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0"
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
## Requires
|
||||
|
||||
* Kotlin 1.1.2
|
||||
* Gradle 3.3
|
||||
* Kotlin 1.3.20
|
||||
* Gradle 4.9
|
||||
|
||||
## Build
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
group 'org.openapitools'
|
||||
version '1.0.0'
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '3.3'
|
||||
wrapper {
|
||||
gradleVersion = '4.9'
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.2'
|
||||
ext.kotlin_version = '1.3.20'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -23,11 +23,16 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
compile "com.squareup.moshi:moshi-kotlin:1.5.0"
|
||||
compile "com.squareup.moshi:moshi-adapters:1.5.0"
|
||||
compile "com.squareup.okhttp3:okhttp:3.8.0"
|
||||
compile "org.threeten:threetenbp:1.3.6"
|
||||
testCompile "io.kotlintest:kotlintest:2.0.2"
|
||||
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0"
|
||||
}
|
||||
|
@ -0,0 +1,101 @@
|
||||
package org.openapitools.client
|
||||
|
||||
import io.kotlintest.shouldBe
|
||||
import io.kotlintest.matchers.numerics.shouldBeGreaterThan
|
||||
import io.kotlintest.specs.ShouldSpec
|
||||
import org.openapitools.client.apis.PetApi
|
||||
import org.openapitools.client.models.Category
|
||||
import org.openapitools.client.models.Pet
|
||||
import org.openapitools.client.models.Tag
|
||||
|
||||
class PetApiTest : ShouldSpec() {
|
||||
init {
|
||||
|
||||
should("add a pet") {
|
||||
val petId:Long = 10006
|
||||
val pet = Pet(
|
||||
id = petId,
|
||||
name = "kotlin client test",
|
||||
photoUrls = arrayOf("http://test_kotlin_unit_test.com"),
|
||||
category = Category(petId, "test kotlin category"),
|
||||
tags = arrayOf(Tag(petId, "test kotlin tag"))
|
||||
)
|
||||
|
||||
val api = PetApi()
|
||||
api.addPet(pet)
|
||||
|
||||
}
|
||||
|
||||
should("get pet by id") {
|
||||
val petId: Long = 10006
|
||||
val api = PetApi()
|
||||
val result = api.getPetById(petId)
|
||||
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client test")
|
||||
result.photoUrls[0] shouldBe ("http://test_kotlin_unit_test.com")
|
||||
result.category!!.id shouldBe (petId)
|
||||
result.category!!.name shouldBe ("test kotlin category")
|
||||
result.tags!![0].id shouldBe (petId)
|
||||
result.tags!![0].name shouldBe ("test kotlin tag")
|
||||
|
||||
}
|
||||
|
||||
should("find pet by status") {
|
||||
val api = PetApi()
|
||||
val result = api.findPetsByStatus(arrayOf("available"))
|
||||
|
||||
result.size.shouldBeGreaterThan(0)
|
||||
|
||||
for(onePet in result) {
|
||||
onePet.status.shouldBe(Pet.Status.available)
|
||||
}
|
||||
|
||||
val result2 = api.findPetsByStatus(arrayOf("unknown_and_incorrect_status"))
|
||||
|
||||
result2.size.shouldBe(0)
|
||||
|
||||
}
|
||||
|
||||
should("update a pet") {
|
||||
val petId:Long = 10007
|
||||
val pet = Pet(
|
||||
id = petId,
|
||||
name = "kotlin client updatePet",
|
||||
status = Pet.Status.pending,
|
||||
photoUrls = arrayOf("http://test_kotlin_unit_test.com")
|
||||
)
|
||||
|
||||
val api = PetApi()
|
||||
api.updatePet(pet)
|
||||
|
||||
// verify updated Pet
|
||||
val result = api.getPetById(petId)
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client updatePet")
|
||||
result.status shouldBe (Pet.Status.pending)
|
||||
|
||||
}
|
||||
|
||||
//TODO the test fail cause client doesn't support other JSON contentType/Accept
|
||||
/*
|
||||
should("update a pet with form") {
|
||||
val petId:Long = 10007
|
||||
val name = "kotlin client updatePet with Form"
|
||||
val status = "pending"
|
||||
|
||||
val api = PetApi()
|
||||
api.updatePetWithForm(petId, name, status)
|
||||
|
||||
// verify updated Pet
|
||||
val result = api.getPetById(petId)
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client updatePet with Form")
|
||||
result.status shouldBe (Pet.Status.pending)
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
|
||||
## Requires
|
||||
|
||||
* Kotlin 1.1.2
|
||||
* Gradle 3.3
|
||||
* Kotlin 1.3.20
|
||||
* Gradle 4.9
|
||||
|
||||
## Build
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
group 'org.openapitools'
|
||||
version '1.0.0'
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '3.3'
|
||||
wrapper {
|
||||
gradleVersion = '4.9'
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.2'
|
||||
ext.kotlin_version = '1.3.20'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -23,11 +23,16 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
compile "com.squareup.moshi:moshi-kotlin:1.5.0"
|
||||
compile "com.squareup.moshi:moshi-adapters:1.5.0"
|
||||
compile "com.squareup.okhttp3:okhttp:3.8.0"
|
||||
compile "org.threeten:threetenbp:1.3.6"
|
||||
testCompile "io.kotlintest:kotlintest:2.0.2"
|
||||
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0"
|
||||
}
|
||||
|
@ -0,0 +1,101 @@
|
||||
package org.openapitools.client
|
||||
|
||||
import io.kotlintest.shouldBe
|
||||
import io.kotlintest.matchers.numerics.shouldBeGreaterThan
|
||||
import io.kotlintest.specs.ShouldSpec
|
||||
import org.openapitools.client.apis.PetApi
|
||||
import org.openapitools.client.models.Category
|
||||
import org.openapitools.client.models.Pet
|
||||
import org.openapitools.client.models.Tag
|
||||
|
||||
class PetApiTest : ShouldSpec() {
|
||||
init {
|
||||
|
||||
should("add a pet") {
|
||||
val petId:Long = 10006
|
||||
val pet = Pet(
|
||||
id = petId,
|
||||
name = "kotlin client test",
|
||||
photoUrls = arrayOf("http://test_kotlin_unit_test.com"),
|
||||
category = Category(petId, "test kotlin category"),
|
||||
tags = arrayOf(Tag(petId, "test kotlin tag"))
|
||||
)
|
||||
|
||||
val api = PetApi()
|
||||
api.addPet(pet)
|
||||
|
||||
}
|
||||
|
||||
should("get pet by id") {
|
||||
val petId: Long = 10006
|
||||
val api = PetApi()
|
||||
val result = api.getPetById(petId)
|
||||
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client test")
|
||||
result.photoUrls[0] shouldBe ("http://test_kotlin_unit_test.com")
|
||||
result.category!!.id shouldBe (petId)
|
||||
result.category!!.name shouldBe ("test kotlin category")
|
||||
result.tags!![0].id shouldBe (petId)
|
||||
result.tags!![0].name shouldBe ("test kotlin tag")
|
||||
|
||||
}
|
||||
|
||||
should("find pet by status") {
|
||||
val api = PetApi()
|
||||
val result = api.findPetsByStatus(arrayOf("available"))
|
||||
|
||||
result.size.shouldBeGreaterThan(0)
|
||||
|
||||
for(onePet in result) {
|
||||
onePet.status.shouldBe(Pet.Status.available)
|
||||
}
|
||||
|
||||
val result2 = api.findPetsByStatus(arrayOf("unknown_and_incorrect_status"))
|
||||
|
||||
result2.size.shouldBe(0)
|
||||
|
||||
}
|
||||
|
||||
should("update a pet") {
|
||||
val petId:Long = 10007
|
||||
val pet = Pet(
|
||||
id = petId,
|
||||
name = "kotlin client updatePet",
|
||||
status = Pet.Status.pending,
|
||||
photoUrls = arrayOf("http://test_kotlin_unit_test.com")
|
||||
)
|
||||
|
||||
val api = PetApi()
|
||||
api.updatePet(pet)
|
||||
|
||||
// verify updated Pet
|
||||
val result = api.getPetById(petId)
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client updatePet")
|
||||
result.status shouldBe (Pet.Status.pending)
|
||||
|
||||
}
|
||||
|
||||
//TODO the test fail cause client doesn't support other JSON contentType/Accept
|
||||
/*
|
||||
should("update a pet with form") {
|
||||
val petId:Long = 10007
|
||||
val name = "kotlin client updatePet with Form"
|
||||
val status = "pending"
|
||||
|
||||
val api = PetApi()
|
||||
api.updatePetWithForm(petId, name, status)
|
||||
|
||||
// verify updated Pet
|
||||
val result = api.getPetById(petId)
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client updatePet with Form")
|
||||
result.status shouldBe (Pet.Status.pending)
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
|
||||
## Requires
|
||||
|
||||
* Kotlin 1.1.2
|
||||
* Gradle 3.3
|
||||
* Kotlin 1.3.20
|
||||
* Gradle 4.9
|
||||
|
||||
## Build
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
group 'org.openapitools'
|
||||
version '1.0.0'
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '3.3'
|
||||
wrapper {
|
||||
gradleVersion = '4.9'
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.2'
|
||||
ext.kotlin_version = '1.3.20'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -23,11 +23,16 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
compile "com.squareup.moshi:moshi-kotlin:1.5.0"
|
||||
compile "com.squareup.moshi:moshi-adapters:1.5.0"
|
||||
compile "com.squareup.okhttp3:okhttp:3.8.0"
|
||||
compile "org.threeten:threetenbp:1.3.6"
|
||||
testCompile "io.kotlintest:kotlintest:2.0.2"
|
||||
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0"
|
||||
}
|
||||
|
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
#Mon May 29 15:39:04 EDT 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
|
@ -0,0 +1,101 @@
|
||||
package org.openapitools.client
|
||||
|
||||
import io.kotlintest.shouldBe
|
||||
import io.kotlintest.matchers.numerics.shouldBeGreaterThan
|
||||
import io.kotlintest.specs.ShouldSpec
|
||||
import org.openapitools.client.apis.PetApi
|
||||
import org.openapitools.client.models.Category
|
||||
import org.openapitools.client.models.Pet
|
||||
import org.openapitools.client.models.Tag
|
||||
|
||||
class PetApiTest : ShouldSpec() {
|
||||
init {
|
||||
|
||||
should("add a pet") {
|
||||
val petId:Long = 10006
|
||||
val pet = Pet(
|
||||
id = petId,
|
||||
name = "kotlin client test",
|
||||
photoUrls = arrayOf("http://test_kotlin_unit_test.com"),
|
||||
category = Category(petId, "test kotlin category"),
|
||||
tags = arrayOf(Tag(petId, "test kotlin tag"))
|
||||
)
|
||||
|
||||
val api = PetApi()
|
||||
api.addPet(pet)
|
||||
|
||||
}
|
||||
|
||||
should("get pet by id") {
|
||||
val petId: Long = 10006
|
||||
val api = PetApi()
|
||||
val result = api.getPetById(petId)
|
||||
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client test")
|
||||
result.photoUrls[0] shouldBe ("http://test_kotlin_unit_test.com")
|
||||
result.category!!.id shouldBe (petId)
|
||||
result.category!!.name shouldBe ("test kotlin category")
|
||||
result.tags!![0].id shouldBe (petId)
|
||||
result.tags!![0].name shouldBe ("test kotlin tag")
|
||||
|
||||
}
|
||||
|
||||
should("find pet by status") {
|
||||
val api = PetApi()
|
||||
val result = api.findPetsByStatus(arrayOf("available"))
|
||||
|
||||
result.size.shouldBeGreaterThan(0)
|
||||
|
||||
for(onePet in result) {
|
||||
onePet.status.shouldBe(Pet.Status.available)
|
||||
}
|
||||
|
||||
val result2 = api.findPetsByStatus(arrayOf("unknown_and_incorrect_status"))
|
||||
|
||||
result2.size.shouldBe(0)
|
||||
|
||||
}
|
||||
|
||||
should("update a pet") {
|
||||
val petId:Long = 10007
|
||||
val pet = Pet(
|
||||
id = petId,
|
||||
name = "kotlin client updatePet",
|
||||
status = Pet.Status.pending,
|
||||
photoUrls = arrayOf("http://test_kotlin_unit_test.com")
|
||||
)
|
||||
|
||||
val api = PetApi()
|
||||
api.updatePet(pet)
|
||||
|
||||
// verify updated Pet
|
||||
val result = api.getPetById(petId)
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client updatePet")
|
||||
result.status shouldBe (Pet.Status.pending)
|
||||
|
||||
}
|
||||
|
||||
//TODO the test fail cause client doesn't support other JSON contentType/Accept
|
||||
/*
|
||||
should("update a pet with form") {
|
||||
val petId:Long = 10007
|
||||
val name = "kotlin client updatePet with Form"
|
||||
val status = "pending"
|
||||
|
||||
val api = PetApi()
|
||||
api.updatePetWithForm(petId, name, status)
|
||||
|
||||
// verify updated Pet
|
||||
val result = api.getPetById(petId)
|
||||
result.id shouldBe (petId)
|
||||
result.name shouldBe ("kotlin client updatePet with Form")
|
||||
result.status shouldBe (Pet.Status.pending)
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user