Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 1b13c69

Browse files
committed
Fix sonar bug
1 parent ef28dca commit 1b13c69

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

graphql-kickstart-spring-boot-autoconfigure-webflux/src/test/java/graphql/kickstart/spring/webflux/boot/MonoAutoConfigurationTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.io.IOException;
66
import lombok.RequiredArgsConstructor;
77
import lombok.val;
8+
import org.json.JSONException;
9+
import org.json.JSONObject;
810
import org.junit.jupiter.api.Test;
911
import org.junit.jupiter.api.extension.ExtendWith;
1012
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,15 +25,16 @@ class MonoAutoConfigurationTest {
2325
private WebTestClient webTestClient;
2426

2527
@Test
26-
void monoWrapper() throws IOException {
28+
void monoWrapper() throws IOException, JSONException {
2729
val result = webTestClient.post()
2830
.uri("/graphql")
2931
.contentType(MediaType.APPLICATION_JSON)
3032
.bodyValue("{ \"query\": \"query { hello } \"}")
3133
.exchange()
3234
.returnResult(String.class);
3335
val response = result.getResponseBody().blockFirst();
34-
assertThat(response).isEqualTo("{\"data\":{\"hello\":\"Hello world\"}}");
36+
val json = new JSONObject(response);
37+
assertThat(json.getJSONObject("data").get("hello")).isEqualTo("Hello world");
3538
}
3639

3740
}

graphql-kickstart-spring-boot-autoconfigure-webflux/src/test/java/graphql/kickstart/spring/webflux/boot/MonoGenericWrapperAlreadyDefinedTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.IOException;
77
import lombok.RequiredArgsConstructor;
88
import lombok.val;
9+
import org.json.JSONException;
10+
import org.json.JSONObject;
911
import org.junit.jupiter.api.Test;
1012
import org.junit.jupiter.api.extension.ExtendWith;
1113
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,15 +29,16 @@ class MonoGenericWrapperAlreadyDefinedTest {
2729
private WebTestClient webTestClient;
2830

2931
@Test
30-
void monoWrapper() throws IOException {
32+
void monoWrapper() throws IOException, JSONException {
3133
val result = webTestClient.post()
3234
.uri("/graphql")
3335
.contentType(MediaType.APPLICATION_JSON)
3436
.bodyValue("{ \"query\": \"query { hello } \"}")
3537
.exchange()
3638
.returnResult(String.class);
3739
val response = result.getResponseBody().blockFirst();
38-
assertThat(response).isEqualTo("{\"data\":{\"hello\":\"Hello world\"}}");
40+
val json = new JSONObject(response);
41+
assertThat(json.getJSONObject("data").get("hello")).isEqualTo("Hello world");
3942
}
4043

4144
@TestConfiguration

0 commit comments

Comments
 (0)