-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: model tests check generation into multiple files (#283)
This changes the ModelGeneratorTest so that it checks all files that would normally be generated. Removes the old Models.kt file and replaces it with the single files
- Loading branch information
Showing
192 changed files
with
3,467 additions
and
2,760 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
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package com.cjbooms.fabrikt.util | ||
|
||
import java.io.FileNotFoundException | ||
import java.nio.file.Path | ||
import kotlin.io.path.listDirectoryEntries | ||
import kotlin.io.path.name | ||
import kotlin.io.path.readText | ||
|
||
object ResourceHelper { | ||
fun readTextResource(path: String): String = | ||
(javaClass.getResource(path) ?: throw FileNotFoundException(path)).readText() | ||
|
||
fun readFolder(path: Path): Map<String, String> = | ||
path.listDirectoryEntries().associate { it.name to it.readText() } | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/resources/examples/anyOfOneOfAllOf/models/ComplexParent.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,32 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import java.math.BigDecimal | ||
import javax.validation.constraints.NotNull | ||
import kotlin.Any | ||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public data class ComplexParent( | ||
@param:JsonProperty("oneOf") | ||
@get:JsonProperty("oneOf") | ||
public val oneOf: Any? = null, | ||
@param:JsonProperty("first_nested_any_of_prop") | ||
@get:JsonProperty("first_nested_any_of_prop") | ||
public val firstNestedAnyOfProp: String? = null, | ||
@param:JsonProperty("second_nested_any_of_prop") | ||
@get:JsonProperty("second_nested_any_of_prop") | ||
public val secondNestedAnyOfProp: String? = null, | ||
@param:JsonProperty("required_string") | ||
@get:JsonProperty("required_string") | ||
@get:NotNull | ||
public val requiredString: String, | ||
@param:JsonProperty("required_int") | ||
@get:JsonProperty("required_int") | ||
@get:NotNull | ||
public val requiredInt: Int, | ||
@param:JsonProperty("top_level_prop") | ||
@get:JsonProperty("top_level_prop") | ||
@get:NotNull | ||
public val topLevelProp: BigDecimal, | ||
) |
12 changes: 12 additions & 0 deletions
12
src/test/resources/examples/anyOfOneOfAllOf/models/ComplexSecondOneA.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,12 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import javax.validation.constraints.NotNull | ||
import kotlin.String | ||
|
||
public data class ComplexSecondOneA( | ||
@param:JsonProperty("more_nested_prop_one") | ||
@get:JsonProperty("more_nested_prop_one") | ||
@get:NotNull | ||
public val moreNestedPropOne: String, | ||
) |
13 changes: 13 additions & 0 deletions
13
src/test/resources/examples/anyOfOneOfAllOf/models/ContainsNestedAnyOf.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,13 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.String | ||
|
||
public data class ContainsNestedAnyOf( | ||
@param:JsonProperty("first_nested_any_of_prop") | ||
@get:JsonProperty("first_nested_any_of_prop") | ||
public val firstNestedAnyOfProp: String? = null, | ||
@param:JsonProperty("second_nested_any_of_prop") | ||
@get:JsonProperty("second_nested_any_of_prop") | ||
public val secondNestedAnyOfProp: String? = null, | ||
) |
10 changes: 10 additions & 0 deletions
10
src/test/resources/examples/anyOfOneOfAllOf/models/FirstAnyA.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,10 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.String | ||
|
||
public data class FirstAnyA( | ||
@param:JsonProperty("first_nested_any_of_prop") | ||
@get:JsonProperty("first_nested_any_of_prop") | ||
public val firstNestedAnyOfProp: String? = null, | ||
) |
10 changes: 10 additions & 0 deletions
10
src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneA.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,10 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.String | ||
|
||
public data class FirstOneA( | ||
@param:JsonProperty("first_nested_one_of_prop") | ||
@get:JsonProperty("first_nested_one_of_prop") | ||
public val firstNestedOneOfProp: String? = null, | ||
) |
10 changes: 10 additions & 0 deletions
10
src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneB.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,10 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.String | ||
|
||
public data class FirstOneB( | ||
@param:JsonProperty("first_property") | ||
@get:JsonProperty("first_property") | ||
public val firstProperty: String? = null, | ||
) |
132 changes: 0 additions & 132 deletions
132
src/test/resources/examples/anyOfOneOfAllOf/models/Models.kt
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/test/resources/examples/anyOfOneOfAllOf/models/MoreNesting.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,12 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import javax.validation.constraints.NotNull | ||
import kotlin.String | ||
|
||
public data class MoreNesting( | ||
@param:JsonProperty("more_nested_prop_one") | ||
@get:JsonProperty("more_nested_prop_one") | ||
@get:NotNull | ||
public val moreNestedPropOne: String, | ||
) |
26 changes: 26 additions & 0 deletions
26
src/test/resources/examples/anyOfOneOfAllOf/models/OneOfAdditionalProps.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,26 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonAnyGetter | ||
import com.fasterxml.jackson.`annotation`.JsonAnySetter | ||
import com.fasterxml.jackson.`annotation`.JsonIgnore | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.Any | ||
import kotlin.String | ||
import kotlin.collections.Map | ||
import kotlin.collections.MutableMap | ||
|
||
public data class OneOfAdditionalProps( | ||
@param:JsonProperty("second_nested_any_of_prop") | ||
@get:JsonProperty("second_nested_any_of_prop") | ||
public val secondNestedAnyOfProp: String? = null, | ||
@get:JsonIgnore | ||
public val properties: MutableMap<String, Any?> = mutableMapOf(), | ||
) { | ||
@JsonAnyGetter | ||
public fun `get`(): Map<String, Any?> = properties | ||
|
||
@JsonAnySetter | ||
public fun `set`(name: String, `value`: Any?) { | ||
properties[name] = value | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/resources/examples/anyOfOneOfAllOf/models/SecondAnyA.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,10 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.String | ||
|
||
public data class SecondAnyA( | ||
@param:JsonProperty("second_nested_any_of_prop") | ||
@get:JsonProperty("second_nested_any_of_prop") | ||
public val secondNestedAnyOfProp: String? = null, | ||
) |
17 changes: 17 additions & 0 deletions
17
src/test/resources/examples/anyOfOneOfAllOf/models/SecondOneB.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,17 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.Any | ||
import kotlin.String | ||
|
||
public data class SecondOneB( | ||
@param:JsonProperty("second_property") | ||
@get:JsonProperty("second_property") | ||
public val secondProperty: String? = null, | ||
@param:JsonProperty("third_property") | ||
@get:JsonProperty("third_property") | ||
public val thirdProperty: String? = null, | ||
@param:JsonProperty("forth_property") | ||
@get:JsonProperty("forth_property") | ||
public val forthProperty: Any? = null, | ||
) |
13 changes: 13 additions & 0 deletions
13
src/test/resources/examples/anyOfOneOfAllOf/models/SimpleOneOfs.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,13 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import kotlin.Any | ||
|
||
public data class SimpleOneOfs( | ||
@param:JsonProperty("oneof_property") | ||
@get:JsonProperty("oneof_property") | ||
public val oneofProperty: Any? = null, | ||
@param:JsonProperty("primitive_oneof_property") | ||
@get:JsonProperty("primitive_oneof_property") | ||
public val primitiveOneofProperty: Any? = null, | ||
) |
17 changes: 17 additions & 0 deletions
17
src/test/resources/examples/anyOfOneOfAllOf/models/SimpleTypeWithRequiredProps.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,17 @@ | ||
package examples.anyOfOneOfAllOf.models | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import javax.validation.constraints.NotNull | ||
import kotlin.Int | ||
import kotlin.String | ||
|
||
public data class SimpleTypeWithRequiredProps( | ||
@param:JsonProperty("required_string") | ||
@get:JsonProperty("required_string") | ||
@get:NotNull | ||
public val requiredString: String, | ||
@param:JsonProperty("required_int") | ||
@get:JsonProperty("required_int") | ||
@get:NotNull | ||
public val requiredInt: Int, | ||
) |
Oops, something went wrong.