From db09b49b9e336b48d1d8e8a937ed53834a88689d Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Sat, 21 Dec 2024 19:42:10 +0200 Subject: [PATCH] Added WS gateway tests --- .../gateway/websocket/WebsocketGatewayTest.java | 13 +++++++++++++ .../websocket/WebsocketLocalGatewayTest.java | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java index ea990fc9c..1a0306cc3 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketGatewayTest.java @@ -1,6 +1,7 @@ package io.scalecube.services.gateway.websocket; import static io.scalecube.services.gateway.GatewayErrorMapperImpl.ERROR_MAPPER; +import static org.junit.jupiter.api.Assertions.assertEquals; import io.scalecube.services.Address; import io.scalecube.services.Microservices; @@ -241,4 +242,16 @@ void shouldHeartbeat() { .assertNext(pongValue -> Assertions.assertEquals(value, pongValue)) .verifyComplete(); } + + @Test + void shouldWorkWithDynamicQualifier() { + final var value = "12345"; + final var data = System.currentTimeMillis(); + final var request = + ServiceMessage.builder().qualifier("greeting/hello/" + value).data(data).build(); + + StepVerifier.create(serviceCall.requestOne(request, String.class).map(ServiceMessage::data)) + .assertNext(result -> assertEquals(value + "@" + data, result)) + .verifyComplete(); + } } diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java index 44e60d807..2e153e9ca 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/websocket/WebsocketLocalGatewayTest.java @@ -1,6 +1,7 @@ package io.scalecube.services.gateway.websocket; import static io.scalecube.services.gateway.GatewayErrorMapperImpl.ERROR_MAPPER; +import static org.junit.jupiter.api.Assertions.assertEquals; import io.scalecube.services.Address; import io.scalecube.services.Microservices; @@ -212,4 +213,16 @@ void shouldReturnSomeExceptionOnFlux() { void shouldReturnSomeExceptionOnMono() { StepVerifier.create(errorService.oneError()).expectError(SomeException.class).verify(TIMEOUT); } + + @Test + void shouldWorkWithDynamicQualifier() { + final var value = "12345"; + final var data = System.currentTimeMillis(); + final var request = + ServiceMessage.builder().qualifier("greeting/hello/" + value).data(data).build(); + + StepVerifier.create(serviceCall.requestOne(request, String.class).map(ServiceMessage::data)) + .assertNext(result -> assertEquals(value + "@" + data, result)) + .verifyComplete(); + } }