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

Commit ef28dca

Browse files
committed
Increase coverage webflux starter
1 parent 838f20a commit ef28dca

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.springframework.test.context.junit.jupiter.SpringExtension;
1414
import org.springframework.test.web.reactive.server.WebTestClient;
1515

16-
@SuppressWarnings("ALL")
16+
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
1717
@RequiredArgsConstructor
1818
@ExtendWith(SpringExtension.class)
1919
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package graphql.kickstart.spring.webflux.boot;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import graphql.kickstart.tools.SchemaParserOptions.GenericWrapper;
6+
import java.io.IOException;
7+
import lombok.RequiredArgsConstructor;
8+
import lombok.val;
9+
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.extension.ExtendWith;
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.boot.test.context.SpringBootTest;
13+
import org.springframework.boot.test.context.TestConfiguration;
14+
import org.springframework.context.annotation.Bean;
15+
import org.springframework.http.MediaType;
16+
import org.springframework.test.context.junit.jupiter.SpringExtension;
17+
import org.springframework.test.web.reactive.server.WebTestClient;
18+
import reactor.core.publisher.Mono;
19+
20+
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
21+
@RequiredArgsConstructor
22+
@ExtendWith(SpringExtension.class)
23+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
24+
class MonoGenericWrapperAlreadyDefinedTest {
25+
26+
@Autowired
27+
private WebTestClient webTestClient;
28+
29+
@Test
30+
void monoWrapper() throws IOException {
31+
val result = webTestClient.post()
32+
.uri("/graphql")
33+
.contentType(MediaType.APPLICATION_JSON)
34+
.bodyValue("{ \"query\": \"query { hello } \"}")
35+
.exchange()
36+
.returnResult(String.class);
37+
val response = result.getResponseBody().blockFirst();
38+
assertThat(response).isEqualTo("{\"data\":{\"hello\":\"Hello world\"}}");
39+
}
40+
41+
@TestConfiguration
42+
static class MonoConfiguration {
43+
@Bean
44+
GenericWrapper genericWrapper() {
45+
return GenericWrapper.withTransformer(
46+
Mono.class,
47+
0,
48+
Mono::toFuture,
49+
t -> t
50+
);
51+
}
52+
}
53+
54+
}

0 commit comments

Comments
 (0)