diff --git a/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClient.java b/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClient.java index 819e757..4fccb98 100644 --- a/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClient.java +++ b/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClient.java @@ -200,8 +200,9 @@ public CompletionStage unsubscribe(UUri topic, UListener listener, Call Objects.requireNonNull(listener, "listener missing"); Objects.requireNonNull(options, "CallOptions missing"); - final UnsubscribeRequest unsubscribeRequest = UnsubscribeRequest.newBuilder().setTopic(topic).build(); - + final UnsubscribeRequest unsubscribeRequest = UnsubscribeRequest.newBuilder().setTopic(topic) + .setSubscriber(SubscriberInfo.newBuilder().setUri(transport.getSource()).build()).build(); + return RpcMapper.mapResponseToResult( // Send the unsubscribe request rpcClient.invokeMethod(UNSUBSCRIBE_METHOD, UPayload.pack(unsubscribeRequest), options), diff --git a/src/test/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClientTest.java b/src/test/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClientTest.java index 14b3033..57499ad 100644 --- a/src/test/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClientTest.java +++ b/src/test/java/org/eclipse/uprotocol/client/usubscription/v3/InMemoryUSubscriptionClientTest.java @@ -403,6 +403,8 @@ public void handleSubscriptionChange(UUri topic, SubscriptionStatus status) { @Test @DisplayName("Test unsubscribe using mock RpcClient and SimplerNotifier") void test_unsubscribe_using_mock_RpcClient_and_SimplerNotifier() { + when(transport.getSource()).thenReturn(this.source); + when(notifier.registerNotificationListener(any(UUri.class), any(UListener.class))) .thenReturn(CompletableFuture.completedFuture(UStatus.newBuilder().setCode(UCode.OK).build())); @@ -434,6 +436,8 @@ void test_unsubscribe_using_mock_RpcClient_and_SimplerNotifier() { @Test @DisplayName("Test unsubscribe using when invokemethod return an exception") void test_unsubscribe_when_invokemethod_return_an_exception() { + when(transport.getSource()).thenReturn(this.source); + when(notifier.registerNotificationListener(any(UUri.class), any(UListener.class))) .thenReturn(CompletableFuture.completedFuture(UStatus.newBuilder().setCode(UCode.OK).build())); @@ -465,6 +469,8 @@ void test_unsubscribe_when_invokemethod_return_an_exception() { @Test @DisplayName("Test unsubscribe when invokemethod returned OK but we failed to unregister the listener") void test_unsubscribe_when_invokemethod_returned_OK_but_we_failed_to_unregister_the_listener() { + when(transport.getSource()).thenReturn(this.source); + when(notifier.registerNotificationListener(any(UUri.class), any(UListener.class))) .thenReturn(CompletableFuture.completedFuture(UStatus.newBuilder().setCode(UCode.OK).build()));