Skip to content

Commit bf22e3c

Browse files
better naming for path_array
1 parent 978b851 commit bf22e3c

13 files changed

+96
-96
lines changed

buildSrc/src/test/kotlin/com/datadog/gradle/plugin/jsonschema/JsonSchemaReaderTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ class JsonSchemaReaderTest(
8888
arrayOf("sets", Video),
8989
arrayOf("one_of_nested", WeirdCombo),
9090
arrayOf("required_for_other_all_of", RequiredForOtherAllOf),
91-
arrayOf("path_array", PathArray),
92-
arrayOf("path_array_2", PathArray2)
91+
arrayOf("path_array_with_integer", PathArrayWithInteger),
92+
arrayOf("path_array_with_number", PathArrayWithNumber)
9393
)
9494
}
9595
}

buildSrc/src/test/kotlin/com/datadog/gradle/plugin/jsonschema/ModelValidationTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ class ModelValidationTest(
208208
arrayOf("constant_number", OutputInfo("Version")),
209209
arrayOf("sets", OutputInfo("Video")),
210210
arrayOf("one_of_nested", OutputInfo("WeirdCombo")),
211-
arrayOf("path_array", OutputInfo("PathArray")),
212-
arrayOf("path_array_2", OutputInfo("PathArray2"))
211+
arrayOf("path_array_with_integer", OutputInfo("PathArrayWithInteger")),
212+
arrayOf("path_array_with_number", OutputInfo("PathArrayWithNumber"))
213213
)
214214
}
215215
}

buildSrc/src/test/kotlin/com/datadog/gradle/plugin/jsonschema/TestDefinitions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,8 @@ val RequiredForOtherAllOf = TypeDefinition.Class(
992992
)
993993
)
994994

995-
val PathArray = TypeDefinition.Class(
996-
name = "PathArray",
995+
val PathArrayWithInteger = TypeDefinition.Class(
996+
name = "PathArrayWithInteger",
997997
properties = listOf(
998998
TypeProperty(
999999
name = "path",
@@ -1049,8 +1049,8 @@ val PathArray = TypeDefinition.Class(
10491049
required = setOf("path")
10501050
)
10511051

1052-
val PathArray2 = TypeDefinition.Class(
1053-
name = "PathArray2",
1052+
val PathArrayWithNumber = TypeDefinition.Class(
1053+
name = "PathArrayWithNumber",
10541054
properties = listOf(
10551055
TypeProperty(
10561056
name = "path",

buildSrc/src/test/kotlin/com/datadog/gradle/plugin/jsonschema/generator/FileGeneratorTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import com.datadog.gradle.plugin.jsonschema.NoOpLogger
2626
import com.datadog.gradle.plugin.jsonschema.Opus
2727
import com.datadog.gradle.plugin.jsonschema.Order
2828
import com.datadog.gradle.plugin.jsonschema.Paper
29-
import com.datadog.gradle.plugin.jsonschema.PathArray
30-
import com.datadog.gradle.plugin.jsonschema.PathArray2
29+
import com.datadog.gradle.plugin.jsonschema.PathArrayWithInteger
30+
import com.datadog.gradle.plugin.jsonschema.PathArrayWithNumber
3131
import com.datadog.gradle.plugin.jsonschema.Person
3232
import com.datadog.gradle.plugin.jsonschema.Product
3333
import com.datadog.gradle.plugin.jsonschema.Shipping
@@ -131,8 +131,8 @@ class FileGeneratorTest(
131131
arrayOf(Version, "Version"),
132132
arrayOf(Video, "Video"),
133133
arrayOf(WeirdCombo, "WeirdCombo"),
134-
arrayOf(PathArray, "PathArray"),
135-
arrayOf(PathArray2, "PathArray2")
134+
arrayOf(PathArrayWithInteger, "PathArrayWithInteger"),
135+
arrayOf(PathArrayWithNumber, "PathArrayWithNumber")
136136
)
137137
}
138138
}

buildSrc/src/test/kotlin/com/example/forgery/ForgeryConfiguration.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal class ForgeryConfiguration : ForgeConfigurator {
3838
forge.addFactory(VersionForgeryFactory())
3939
forge.addFactory(VideoForgeryFactory())
4040
forge.addFactory(WeirdComboForgeryFactory())
41-
forge.addFactory(PathArrayForgeryFactory())
42-
forge.addFactory(PathArray2ForgeryFactory())
41+
forge.addFactory(PathArrayWithIntegerForgeryFactory())
42+
forge.addFactory(PathArrayWithNumberForgeryFactory())
4343
}
4444
}

buildSrc/src/test/kotlin/com/example/forgery/PathArray2ForgeryFactory.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

buildSrc/src/test/kotlin/com/example/forgery/PathArrayForgeryFactory.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2016-Present Datadog, Inc.
5+
*/
6+
7+
package com.example.forgery
8+
9+
import com.example.model.PathArrayWithInteger
10+
import fr.xgouchet.elmyr.Forge
11+
import fr.xgouchet.elmyr.ForgeryFactory
12+
13+
internal class PathArrayWithIntegerForgeryFactory : ForgeryFactory<PathArrayWithInteger> {
14+
override fun getForgery(forge: Forge): PathArrayWithInteger {
15+
return PathArrayWithInteger(
16+
path = forge.aList {
17+
forge.anElementFrom(
18+
listOf(
19+
PathArrayWithInteger.Path.String(forge.aString()),
20+
PathArrayWithInteger.Path.Boolean(forge.aBool()),
21+
PathArrayWithInteger.Path.Point(x = forge.aLong(), y = forge.aLong()),
22+
PathArrayWithInteger.Path.String("true"),
23+
PathArrayWithInteger.Path.String("false"),
24+
PathArrayWithInteger.Path.String("123"),
25+
PathArrayWithInteger.Path.String("123.123"),
26+
PathArrayWithInteger.Path.Long(forge.aLong())
27+
)
28+
)
29+
}
30+
)
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2016-Present Datadog, Inc.
5+
*/
6+
7+
package com.example.forgery
8+
9+
import com.example.model.PathArrayWithNumber
10+
import fr.xgouchet.elmyr.Forge
11+
import fr.xgouchet.elmyr.ForgeryFactory
12+
13+
internal class PathArrayWithNumberForgeryFactory : ForgeryFactory<PathArrayWithNumber> {
14+
override fun getForgery(forge: Forge): PathArrayWithNumber {
15+
return PathArrayWithNumber(
16+
path = forge.aList {
17+
forge.anElementFrom(
18+
listOf(
19+
PathArrayWithNumber.Path.String(forge.aString()),
20+
PathArrayWithNumber.Path.Boolean(forge.aBool()),
21+
PathArrayWithNumber.Path.Point(x = forge.aLong(), y = forge.aLong()),
22+
PathArrayWithNumber.Path.String("true"),
23+
PathArrayWithNumber.Path.String("false"),
24+
PathArrayWithNumber.Path.String("123"),
25+
PathArrayWithNumber.Path.String("123.123"),
26+
PathArrayWithNumber.Path.Number(forge.aNumber())
27+
)
28+
)
29+
}
30+
)
31+
}
32+
}

buildSrc/src/test/kotlin/com/example/model/PathArray.kt renamed to buildSrc/src/test/kotlin/com/example/model/PathArrayWithInteger.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.collections.List
1616
import kotlin.jvm.JvmStatic
1717
import kotlin.jvm.Throws
1818

19-
public data class PathArray(
19+
public data class PathArrayWithInteger(
2020
public val path: List<Path>,
2121
) {
2222
public fun toJson(): JsonElement {
@@ -30,21 +30,21 @@ public data class PathArray(
3030
public companion object {
3131
@JvmStatic
3232
@Throws(JsonParseException::class)
33-
public fun fromJson(jsonString: String): PathArray {
33+
public fun fromJson(jsonString: String): PathArrayWithInteger {
3434
try {
3535
val jsonObject = JsonParser.parseString(jsonString).asJsonObject
3636
return fromJsonObject(jsonObject)
3737
} catch (e: IllegalStateException) {
3838
throw JsonParseException(
39-
"Unable to parse json into type PathArray",
39+
"Unable to parse json into type PathArrayWithInteger",
4040
e
4141
)
4242
}
4343
}
4444

4545
@JvmStatic
4646
@Throws(JsonParseException::class)
47-
public fun fromJsonObject(jsonObject: JsonObject): PathArray {
47+
public fun fromJsonObject(jsonObject: JsonObject): PathArrayWithInteger {
4848
try {
4949
val path = jsonObject.get("path").asJsonArray.let { jsonArray ->
5050
val collection = ArrayList<Path>(jsonArray.size())
@@ -53,20 +53,20 @@ public data class PathArray(
5353
}
5454
collection
5555
}
56-
return PathArray(path)
56+
return PathArrayWithInteger(path)
5757
} catch (e: IllegalStateException) {
5858
throw JsonParseException(
59-
"Unable to parse json into type PathArray",
59+
"Unable to parse json into type PathArrayWithInteger",
6060
e
6161
)
6262
} catch (e: NumberFormatException) {
6363
throw JsonParseException(
64-
"Unable to parse json into type PathArray",
64+
"Unable to parse json into type PathArrayWithInteger",
6565
e
6666
)
6767
} catch (e: NullPointerException) {
6868
throw JsonParseException(
69-
"Unable to parse json into type PathArray",
69+
"Unable to parse json into type PathArrayWithInteger",
7070
e
7171
)
7272
}

0 commit comments

Comments
 (0)