Skip to content

Commit

Permalink
fix #224 (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuseal authored and TedZen committed Aug 31, 2019
1 parent c6d32e5 commit 26035fd
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 5 deletions.
112 changes: 112 additions & 0 deletions src/test/kotlin/wu/seal/jsontokotlin/regression/Issue224Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package wu.seal.jsontokotlin.regression

import com.winterbe.expekt.should
import org.junit.Before
import org.junit.Test
import wu.seal.jsontokotlin.*
import wu.seal.jsontokotlin.test.TestConfig

/**
* Created by Seal.Wu on 2019-08-31
* Description: Test Case For Issue 224
*/
class Issue224Test {
@Before
fun setUp() {
TestConfig.setToTestInitState()
}

@Test
fun test() {
val json = """
{
"${"$$"}schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"address": {
"properties": {
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"street_address": {
"type": "string"
}
},
"required": [
"street_address",
"city",
"state"
],
"type": "object"
}
},
"properties": {
"billing_address": {
"${"$"}ref": "#/definitions/address"
},
"shipping_address": {
"${"$"}ref": "#/definitions/address"
}
},
"type": "object"
}
""".trimIndent()

val expect = """
data class Test(
val `${"$$"}schema`: String = "",
val definitions: Definitions = Definitions(),
val properties: PropertiesX = Properties(),
val type: String = ""
)
data class Definitions(
val address: Address = Address()
)
data class Address(
val properties: Properties = Properties(),
val required: List<String> = listOf(),
val type: String = ""
)
data class Properties(
val city: City = City(),
val state: State = State(),
val street_address: StreetAddress = StreetAddress()
)
data class City(
val type: String = ""
)
data class State(
val type: String = ""
)
data class StreetAddress(
val type: String = ""
)
data class PropertiesX(
val billing_address: BillingAddress = BillingAddress(),
val shipping_address: ShippingAddress = ShippingAddress()
)
data class BillingAddress(
val `${"$"}ref`: String = ""
)
data class ShippingAddress(
val `${"$"}ref`: String = ""
)
""".trimIndent()
TestConfig.isNestedClassModel = false
TestConfig.targetJsonConvertLib = TargetJsonConverter.None
TestConfig.isCommentOff = true
KotlinCodeMaker("Test", json).makeKotlinData().should.be.equal(expect)
}

}

This file was deleted.

0 comments on commit 26035fd

Please sign in to comment.