-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-431-fix
- Loading branch information
Showing
2 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
src/test/kotlin/wu/seal/jsontokotlin/regression/Issue425Test.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,66 @@ | ||
package wu.seal.jsontokotlin.regression | ||
|
||
import com.winterbe.expekt.should | ||
import org.junit.Test | ||
import wu.seal.jsontokotlin.generateKotlinClassCode | ||
import wu.seal.jsontokotlin.model.DefaultValueStrategy | ||
import wu.seal.jsontokotlin.model.TargetJsonConverter | ||
import wu.seal.jsontokotlin.test.TestConfig | ||
import wu.seal.jsontokotlin.utils.BaseTest | ||
|
||
class Issue425Test : BaseTest() { | ||
@Test | ||
fun testIssue425() { | ||
val json = """ | ||
{ | ||
"firstTeam": { | ||
"hometown": { | ||
"name": "Town 1" | ||
}, | ||
"stats": { | ||
"rating": 10 | ||
} | ||
}, | ||
"secondTeam": { | ||
"hometown": { | ||
"name": "Town 2" | ||
}, | ||
"stats": { | ||
"rating": 20 | ||
} | ||
} | ||
} | ||
""".trimIndent() | ||
val expected = """ | ||
data class Match( | ||
val firstTeam: FirstTeam, | ||
val secondTeam: SecondTeam | ||
) | ||
data class FirstTeam( | ||
val hometown: Hometown, | ||
val stats: Stats | ||
) | ||
data class SecondTeam( | ||
val hometown: Hometown, | ||
val stats: Stats | ||
) | ||
data class Hometown( | ||
val name: String | ||
) | ||
data class Stats( | ||
val rating: Int | ||
) | ||
""".trimIndent() | ||
TestConfig.apply { | ||
isCommentOff = true | ||
targetJsonConvertLib = TargetJsonConverter.None | ||
defaultValueStrategy = DefaultValueStrategy.None | ||
isNestedClassModel = false | ||
} | ||
json.generateKotlinClassCode("Match").should.equal(expected) | ||
} | ||
} |