Skip to content

Commit 2c84924

Browse files
committed
update Unit test
1 parent a08622e commit 2c84924

File tree

7 files changed

+96
-52
lines changed

7 files changed

+96
-52
lines changed

src/test/kotlin/wu/seal/jsontokotlin/DataClassMakerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class DataClassMakerTest {
209209
properties.size.should.be.equal(1)
210210
properties[0].run {
211211
name.should.be.equal("k")
212-
originJsonValue.should.be.equal("EMW3168")
212+
originJsonValue.should.be.equal("EMW3165")
213213
type.should.be.equal(KotlinClass.STRING.name)
214214
}
215215
}

src/test/kotlin/wu/seal/jsontokotlin/KotlinClassCodeMakerKtTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class KotlinClassCodeMakerKtTest {
137137
properties.size.should.be.equal(1)
138138
properties[0].run {
139139
name.should.be.equal("k")
140-
originJsonValue.should.be.equal("EMW3168")
140+
originJsonValue.should.be.equal("EMW3165")
141141
type.should.be.equal(TYPE_STRING)
142142
}
143143
}

src/test/kotlin/wu/seal/jsontokotlin/KotlinCodeMakerTest.kt

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,30 @@ class KotlinCodeMakerTest {
222222
]
223223
}
224224
""".trimIndent()
225-
val expected = """data class TestData(
226-
val id: Int, // The unique identifier for a product
227-
val name: String, // Name of the product
225+
val expected = """/**
226+
* A product from Acme's catalog
227+
*/
228+
data class TestData(
229+
/**
230+
* The unique identifier for a product
231+
*/
232+
val id: Int,
233+
/**
234+
* Name of the product
235+
*/
236+
val name: String,
228237
val price: Double,
229-
val nested: nested
238+
val nested: Nested
230239
) {
231-
data class nested(
232-
val id: Int, // The unique identifier for a product
233-
val name: String, // Name of the product
240+
data class Nested(
241+
/**
242+
* The unique identifier for a product
243+
*/
244+
val id: Int,
245+
/**
246+
* Name of the product
247+
*/
248+
val name: String,
234249
val price: Double
235250
)
236251
}""".trimIndent()
@@ -304,21 +319,37 @@ class KotlinCodeMakerTest {
304319
]
305320
}
306321
""".trimIndent()
307-
val expected = """data class TestData(
308-
val id: Int, // The unique identifier for a product
309-
val name: String, // Name of the product
310-
val price: Double,
311-
val nested: nested
312-
) {
313-
data class nested(
314-
val grades: List<String>,
315-
val scores: List<Double>,
316-
val happy: List<Boolean>,
317-
val id: Int, // The unique identifier for a product
318-
val name: String, // Name of the product
319-
val price: Double
320-
)
321-
}""".trimIndent()
322+
val expected = """
323+
/**
324+
* A product from Acme's catalog
325+
*/
326+
data class TestData(
327+
/**
328+
* The unique identifier for a product
329+
*/
330+
val id: Int,
331+
/**
332+
* Name of the product
333+
*/
334+
val name: String,
335+
val price: Double,
336+
val nested: Nested
337+
) {
338+
data class Nested(
339+
val grades: List<String>,
340+
val scores: List<Double>,
341+
val happy: List<Boolean>,
342+
/**
343+
* The unique identifier for a product
344+
*/
345+
val id: Int,
346+
/**
347+
* Name of the product
348+
*/
349+
val name: String,
350+
val price: Double
351+
)
352+
}""".trimIndent()
322353
val dataClass = KotlinClassMaker("TestData", json).makeKotlinClass() as DataClass
323354
dataClass.properties[3].originJsonValue.should.be.`null`
324355
val result = dataClass.getCode()
@@ -356,7 +387,7 @@ class KotlinCodeMakerTest {
356387
)
357388
358389
data class Module(
359-
var k: String = "" // EMW3168
390+
var k: String = "" // EMW3165
360391
)
361392
""".trimIndent()
362393

src/test/kotlin/wu/seal/jsontokotlin/regression/Issue090Test.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ class Issue090Test {
286286
) {
287287
data class Attribute(
288288
@SerializedName("id")
289-
val id: Int = 0, // 0
289+
val id: Int = 0, // 1
290290
@SerializedName("name")
291-
val name: String = "", // Dispenser/Dish
291+
val name: String = "", // Color
292292
@SerializedName("options")
293293
val options: List<String> = listOf(),
294294
@SerializedName("position")
295-
val position: Int = 0, // 1
295+
val position: Int = 0, // 0
296296
@SerializedName("variation")
297297
val variation: Boolean = false, // false
298298
@SerializedName("visible")
@@ -301,11 +301,11 @@ class Issue090Test {
301301
302302
data class Category(
303303
@SerializedName("id")
304-
val id: Int = 0, // 60
304+
val id: Int = 0, // 63
305305
@SerializedName("name")
306-
val name: String = "", // Laundry
306+
val name: String = "", // Accessories
307307
@SerializedName("slug")
308-
val slug: String = "" // laundry
308+
val slug: String = "" // accessories-laundry
309309
)
310310
311311
data class Dimensions(
@@ -366,7 +366,8 @@ class Issue090Test {
366366
@SerializedName("slug")
367367
val slug: String = "" // sale
368368
)
369-
}"""
369+
}
370+
"""
370371

371372
/**
372373
* test before to init test enviroment

src/test/kotlin/wu/seal/jsontokotlin/regression/Issue108Test.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,22 @@ class Issue108Test {
6666
}
6767
}""".trimIndent()
6868
val expected = """data class TestData(
69-
val hourMin: Int, // Начиная с: час (от 0 до 23)
70-
val minuteMin: Int, // Начиная с: минуты (от 0 до 59)
71-
val hourMax: Int, // До: час (от 0 до 23)
72-
val minuteMax: Int // До: минуты (от 0 до 59)
69+
/**
70+
* Начиная с: час (от 0 до 23)
71+
*/
72+
val hourMin: Int,
73+
/**
74+
* Начиная с: минуты (от 0 до 59)
75+
*/
76+
val minuteMin: Int,
77+
/**
78+
* До: час (от 0 до 23)
79+
*/
80+
val hourMax: Int,
81+
/**
82+
* До: минуты (от 0 до 59)
83+
*/
84+
val minuteMax: Int
7385
)""".trimIndent()
7486
val result = KotlinClassMaker("TestData", json).makeKotlinClass().getCode()
7587
result.trim().should.be.equal(expected)

src/test/kotlin/wu/seal/jsontokotlin/regression/Issue121Test.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ class Issue121Test {
4545
@SerializedName("active")
4646
val active: Int = 0, // 1
4747
@SerializedName("answer")
48-
val answer: String = "", // answer
48+
val answer: String = "", // Ok i understand.
4949
@SerializedName("created")
50-
val created: String = "", // 2019-03-28T15:41:52+05:30
50+
val created: String = "", // 2019-03-28T15:37:06+05:30
5151
@SerializedName("created_by")
5252
val createdBy: Int = 0, // 0
5353
@SerializedName("id")
54-
val id: Int = 0, // 2
54+
val id: Int = 0, // 1
5555
@SerializedName("is_del")
5656
val isDel: Int = 0, // 0
5757
@SerializedName("modified")
58-
val modified: String = "", // 2019-03-28T15:41:52+05:30
58+
val modified: String = "", // 2019-03-28T15:37:06+05:30
5959
@SerializedName("modified_by")
6060
val modifiedBy: Int = 0, // 0
6161
@SerializedName("question")
62-
val question: String = "" // What is soulmate?
62+
val question: String = "" // This is test question?
6363
)
6464
}"""
6565

src/test/kotlin/wu/seal/jsontokotlin/regression/Issue170Test.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ class Issue170Test {
3030
"}"
3131

3232

33-
private val expected = "data class A(\n" +
34-
" @SerializedName(\"employees\")\n" +
35-
" val employees: List<Employee>\n" +
36-
") {\n" +
37-
" data class Employee(\n" +
38-
" @SerializedName(\"firstName\")\n" +
39-
" val firstName: String?, // Thomas\n" +
40-
" @SerializedName(\"lastName\")\n" +
41-
" val lastName: String // Carter\n" +
42-
" )\n" +
43-
"}"
33+
private val expected = """data class A(
34+
@SerializedName("employees")
35+
val employees: List<Employee>
36+
) {
37+
data class Employee(
38+
@SerializedName("firstName")
39+
val firstName: String?, // Bill
40+
@SerializedName("lastName")
41+
val lastName: String // Gates
42+
)
43+
}"""
4444

4545

4646

0 commit comments

Comments
 (0)