I have been referring to this https://docs.spring.io/spring-graphql/docs/current/reference/html/#testing to setup test for the subscriptionMapping
However when I run the test the subscription start but does not emit the message and ends up in a hangup state.
Can someone help me in what am I missing
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
class SubscriptionControllerTest {
val client: WebSocketClient = ReactorNettyWebSocketClient()
val tester = WebSocketGraphQlTester.builder(url, client)
.build()
@Test
fun createTestSubscription() {
val responseFlux: Flux = tester.document(
"subscription ($var1: String, $var2: String) {n" +
" testSubscription(var1: $var1, var2: $var2) {n" +
" valuen" +
"}"
).variable("var1", var1).variable("var2", var2)
.executeSubscription()
.toFlux("testSubscription",DTO::class.java)
subscriptionService.publish(sampleData)
StepVerifier
.create(responseFlux)
.expectSubscription()
.expectNext(sampleData)
.verifyComplete()
}
}