Skip to content

Commit 2e8f45c

Browse files
authored
Merge pull request #2274 from Netflix/cleanup-2026-02-03
Various clean up
2 parents dc32d4b + 2d1452b commit 2e8f45c

File tree

49 files changed

+247
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+247
-221
lines changed

graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphqlSSESubscriptionGraphQLClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import reactor.core.scheduler.Schedulers
3333
class GraphqlSSESubscriptionGraphQLClient(
3434
private val url: String,
3535
private val webClient: WebClient,
36-
private val options: GraphQLRequestOptions? = null,
36+
options: GraphQLRequestOptions? = null,
3737
) : ReactiveGraphQLClient {
3838
constructor(url: String, webClient: WebClient) : this(url, webClient, null)
3939

graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/RestClientGraphQLClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
2020
import org.intellij.lang.annotations.Language
2121
import org.springframework.http.HttpHeaders
2222
import org.springframework.web.client.RestClient
23+
import org.springframework.web.client.toEntity
2324
import java.util.function.Consumer
2425

2526
/**
@@ -103,7 +104,7 @@ class RestClientGraphQLClient(
103104
}.headers(this.headersConsumer)
104105
.body(serializedRequest)
105106
.retrieve()
106-
.toEntity(String::class.java)
107+
.toEntity<String>()
107108

108109
if (!responseEntity.statusCode.is2xxSuccessful) {
109110
throw GraphQLClientException(

graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/SSESubscriptionGraphQLClient.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import org.springframework.web.reactive.function.client.WebClient
2525
import org.springframework.web.reactive.function.client.toEntityFlux
2626
import reactor.core.publisher.Flux
2727
import reactor.core.scheduler.Schedulers
28-
import java.nio.charset.StandardCharsets
29-
import java.util.Base64
28+
import kotlin.io.encoding.Base64
3029

3130
/*
3231
* This client can be used for servers which are following the subscriptions-transport-sse specification, which can be found here:
@@ -72,10 +71,10 @@ class SSESubscriptionGraphQLClient(
7271

7372
private fun encodeQuery(
7473
@Language("graphql") query: String,
75-
): String? = Base64.getEncoder().encodeToString(query.toByteArray(StandardCharsets.UTF_8))
74+
): String = Base64.encode(query.encodeToByteArray())
7675
}
7776

78-
private fun org.springframework.http.HttpHeaders.toMap(): Map<String, List<String>> {
77+
private fun HttpHeaders.toMap(): Map<String, List<String>> {
7978
val result = mutableMapOf<String, List<String>>()
8079
this.forEach { key, values -> result[key] = values }
8180
return result

graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/WebClientGraphQLClient.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.netflix.graphql.dgs.client
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper
20-
import com.netflix.graphql.dgs.client.WebClientGraphQLClient.RequestBodyUriCustomizer
2120
import org.intellij.lang.annotations.Language
2221
import org.springframework.http.HttpHeaders
2322
import org.springframework.http.ResponseEntity

graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/CustomGraphQLClientTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.springframework.http.HttpEntity
3434
import org.springframework.http.HttpHeaders
3535
import org.springframework.http.HttpMethod
3636
import org.springframework.web.client.RestTemplate
37+
import org.springframework.web.client.exchange
3738

3839
@SpringBootTest(
3940
classes = [WebClientGraphQLClientTest.TestApp::class],
@@ -53,9 +54,9 @@ class CustomGraphQLClientTest {
5354
client =
5455
GraphQLClient.createCustom("http://localhost:$port/graphql") { url, headers, body ->
5556
val httpHeaders = HttpHeaders()
56-
headers.forEach { key, values -> httpHeaders.addAll(key, values) }
57+
headers.forEach { (key, values) -> httpHeaders.addAll(key, values) }
5758

58-
val exchange = restTemplate.exchange(url, HttpMethod.POST, HttpEntity(body, httpHeaders), String::class.java)
59+
val exchange = restTemplate.exchange<String>(url, HttpMethod.POST, HttpEntity(body, httpHeaders))
5960
HttpResponse(exchange.statusCode.value(), exchange.body)
6061
}
6162
}

graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/CustomReactiveGraphQLClientTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CustomReactiveGraphQLClientTest {
5050
client =
5151
MonoGraphQLClient.createCustomReactive("http://localhost:$port/graphql") { url, headers, body ->
5252
val httpHeaders = HttpHeaders()
53-
headers.forEach { key, values -> httpHeaders.addAll(key, values) }
53+
headers.forEach { (key, values) -> httpHeaders.addAll(key, values) }
5454

5555
WebClient
5656
.create(url)

graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/ErrorsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import org.springframework.test.web.client.match.MockRestRequestMatchers.method
2828
import org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo
2929
import org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess
3030
import org.springframework.web.client.RestTemplate
31+
import org.springframework.web.client.exchange
3132

3233
class ErrorsTest {
3334
private val restTemplate = RestTemplate()
@@ -36,9 +37,9 @@ class ErrorsTest {
3637
private val requestExecutor =
3738
RequestExecutor { url, headers, body ->
3839
val httpHeaders = HttpHeaders()
39-
headers.forEach { key, values -> httpHeaders.addAll(key, values) }
40+
headers.forEach { (key, values) -> httpHeaders.addAll(key, values) }
4041

41-
val exchange = restTemplate.exchange(url, HttpMethod.POST, HttpEntity(body, httpHeaders), String::class.java)
42+
val exchange = restTemplate.exchange<String>(url, HttpMethod.POST, HttpEntity(body, httpHeaders))
4243
HttpResponse(statusCode = exchange.statusCode.value(), body = exchange.body)
4344
}
4445

graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/GraphQLResponseTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.springframework.test.web.client.match.MockRestRequestMatchers.method
3434
import org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo
3535
import org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess
3636
import org.springframework.web.client.RestTemplate
37+
import org.springframework.web.client.exchange
3738
import java.time.OffsetDateTime
3839

3940
class GraphQLResponseTest {
@@ -43,9 +44,9 @@ class GraphQLResponseTest {
4344
private val requestExecutor =
4445
RequestExecutor { url, headers, body ->
4546
val httpHeaders = HttpHeaders()
46-
headers.forEach { key, values -> httpHeaders.addAll(key, values) }
47+
headers.forEach { (key, values) -> httpHeaders.addAll(key, values) }
4748

48-
val response = restTemplate.exchange(url, HttpMethod.POST, HttpEntity(body, httpHeaders), String::class.java)
49+
val response = restTemplate.exchange<String>(url, HttpMethod.POST, HttpEntity(body, httpHeaders))
4950
HttpResponse(statusCode = response.statusCode.value(), body = response.body, headers = response.headers.toMap())
5051
}
5152

graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/ReactiveWebClientTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test
2424
import org.springframework.http.HttpStatus
2525
import org.springframework.web.reactive.function.client.ClientResponse
2626
import org.springframework.web.reactive.function.client.WebClient
27+
import org.springframework.web.reactive.function.client.toEntity
2728
import reactor.core.publisher.Mono
2829
import java.time.Duration
2930
import java.time.LocalDate
@@ -46,10 +47,10 @@ class ReactiveWebClientTest {
4647
}.build()
4748
.post()
4849
.uri(url)
49-
.headers { consumer -> headers.forEach { key, values -> consumer.addAll(key, values) } }
50+
.headers { consumer -> headers.forEach { (key, values) -> consumer.addAll(key, values) } }
5051
.bodyValue(body)
5152
.retrieve()
52-
.toEntity(String::class.java)
53+
.toEntity<String>()
5354
.map { response -> HttpResponse(response.statusCode.value(), response.body) }
5455
}
5556

@@ -65,7 +66,7 @@ class ReactiveWebClientTest {
6566
val mapper = ObjectMapper().registerModules(JavaTimeModule())
6667
val responseMono =
6768
CustomMonoGraphQLClient(url, requestExecutor, mapper).reactiveExecuteQuery(
68-
"{ hello(${'$'}input: HelloInput!) }",
69+
$$"{ hello($input: HelloInput!) }",
6970
mapOf("foo" to LocalDate.now()),
7071
)
7172
val graphQLResponse = responseMono.block(Duration.ZERO) ?: fail("Expected non-null response")

graphql-dgs-client/src/test/kotlin/com/netflix/graphql/dgs/client/WebSocketGraphQLClientTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ class WebSocketGraphQLClientTest {
6767
companion object {
6868
private val VERIFY_TIMEOUT = Duration.ofSeconds(10)
6969
private val CONNECTION_ACK_MESSAGE = OperationMessage(GQL_CONNECTION_ACK, null, null)
70-
private val TEST_DATA_A = mapOf(Pair("a", 1), Pair("b", "hello"), Pair("c", false))
71-
private val TEST_DATA_B = mapOf(Pair("a", 2), Pair("b", null), Pair("c", true))
72-
private val TEST_DATA_C = mapOf(Pair("a", 3), Pair("b", "world"), Pair("c", false))
70+
private val TEST_DATA_A = mapOf("a" to 1, "b" to "hello", "c" to false)
71+
private val TEST_DATA_B = mapOf("a" to 2, "b" to null, "c" to true)
72+
private val TEST_DATA_C = mapOf("a" to 3, "b" to "world", "c" to false)
7373
}
7474

7575
lateinit var subscriptionsClient: OperationMessageWebSocketClient

0 commit comments

Comments
 (0)