-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
src/test/kotlin/wu/seal/jsontokotlin/regression/Issue224Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
} |
5 changes: 0 additions & 5 deletions
5
src/test/kotlin/wu/seal/jsontokotlin/regression/package-info.java
This file was deleted.
Oops, something went wrong.