Skip to content

Commit

Permalink
bug fix, unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kkatelia committed Dec 20, 2024
1 parent 4bc73d1 commit b1b64f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ class InputTypeGenerator(config: CodeGenConfig, document: Document) : BaseDataTy
.plus(
extensions
.asSequence()
.flatMap { it.fieldDefinitions() }
.filterSkipped()
.flatMap { it.inputValueDefinitions }
.map { Field(it.name, typeUtils.findReturnType(it.type, useInterfaceType, true)) }
)
.toList()
Expand All @@ -198,7 +197,7 @@ class InputTypeGenerator(config: CodeGenConfig, document: Document) : BaseDataTy
}

val fieldDefinitions = definition.inputValueDefinitions.asSequence().map {
val type = typeUtils.findReturnType(it.type, useInterfaceType)
val type = typeUtils.findReturnType(it.type)
val defaultValue = it.defaultValue?.let { defVal ->
generateCode(defVal, type, inputTypeDefinitions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3168,7 +3168,7 @@ class CodeGenTest {
val interfaces = result.javaInterfaces
val dataTypes = result.javaDataTypes

assertThat(interfaces).hasSize(4) // IMovie, IMoviePage, IGenre, IRating
assertThat(interfaces).hasSize(5) // IMovie, IMoviePage, IGenre, IRating, IMovieFilter
assertThat(dataTypes).hasSize(5) // Movie, MoviePage, Genre, Rating, MovieFilter

val iMovie = interfaces[0]
Expand Down Expand Up @@ -3199,6 +3199,10 @@ class CodeGenTest {
assertThat(iRating.typeSpec.name).isEqualTo("IRating")
assertThat(iRating.typeSpec.methodSpecs).extracting("name").containsExactly("getName")

val iMovieFilter = interfaces[4]
assertThat(iMovieFilter.typeSpec.name).isEqualTo("IMovieFilter")
assertThat(iMovieFilter.typeSpec.methodSpecs).extracting("name").containsExactly("getTitle", "getGenre", "getLanguage", "getTags", "getRating")

val movie = dataTypes[0]
assertThat(movie.typeSpec.name).isEqualTo("Movie")
assertThat(movie.typeSpec.superinterfaces).extracting("simpleName").containsExactly("IMovie")
Expand Down Expand Up @@ -3233,7 +3237,7 @@ class CodeGenTest {

val movieFilter = dataTypes[4]
assertThat(movieFilter.typeSpec.name).isEqualTo("MovieFilter")
assertThat(movieFilter.typeSpec.superinterfaces.size).isEqualTo(0)
assertThat(movieFilter.typeSpec.superinterfaces.size).isEqualTo(1) //IMovieFilter
assertThat(movieFilter.typeSpec.fieldSpecs).extracting("name").containsExactly("title", "genre", "language", "tags", "rating")
assertThat(movieFilter.typeSpec.fieldSpecs[0].type).extracting("simpleName").isEqualTo("String")
assertThat(movieFilter.typeSpec.fieldSpecs[1].type).extracting("simpleName").isEqualTo("Genre")
Expand Down

0 comments on commit b1b64f3

Please sign in to comment.