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 4fccb98..e1600a3 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 @@ -295,7 +295,6 @@ public CompletionStage registerForNotifications(UUri topi * Unregister for subscription change notifications. * * @param topic The topic to unregister for notifications. - * @param handler The {@link SubscriptionChangeHandler} to handle the subscription changes. * @param options The {@link CallOptions} to be used for the unregister request. * @return {@link CompletionStage} completed successfully with {@link NotificationResponse} with * the status of the API call to uSubscription service, or completed unsuccessfully with @@ -303,10 +302,8 @@ public CompletionStage registerForNotifications(UUri topi * returned if the topic ue_id does not equal the callers ue_id. */ @Override - public CompletionStage unregisterForNotifications(UUri topic, - SubscriptionChangeHandler handler, CallOptions options) { + public CompletionStage unregisterForNotifications(UUri topic, CallOptions options) { Objects.requireNonNull(topic, "Topic missing"); - Objects.requireNonNull(handler, "Handler missing"); Objects.requireNonNull(options, "CallOptions missing"); NotificationsRequest request = NotificationsRequest.newBuilder() diff --git a/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/USubscriptionClient.java b/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/USubscriptionClient.java index d64c12e..9c012de 100644 --- a/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/USubscriptionClient.java +++ b/src/main/java/org/eclipse/uprotocol/client/usubscription/v3/USubscriptionClient.java @@ -177,14 +177,12 @@ CompletionStage registerForNotifications(UUri topic, * Unregister for subscription change notifications. * * @param topic The topic to unregister for notifications. - * @param handler The {@link SubscriptionChangeHandler} to be unregistered. * @return {@link CompletionStage} completed successfully with {@link NotificationResponse} with * the status of the API call to uSubscription service, or completed unsuccessfully with * {@link UStatus} with the reason for the failure. */ - default CompletionStage unregisterForNotifications(UUri topic, - SubscriptionChangeHandler handler) { - return unregisterForNotifications(topic, handler, CallOptions.DEFAULT); + default CompletionStage unregisterForNotifications(UUri topic) { + return unregisterForNotifications(topic, CallOptions.DEFAULT); } @@ -192,14 +190,12 @@ default CompletionStage unregisterForNotifications(UUri t * Unregister for subscription change notifications. * * @param topic The topic to unregister for notifications. - * @param handler The {@link SubscriptionChangeHandler} to be unregistered. * @param options The {@link CallOptions} to be used for the request. * @return {@link CompletionStage} completed successfully with {@link NotificationResponse} with * the status of the API call to uSubscription service, or completed unsuccessfully with * {@link UStatus} with the reason for the failure. */ - CompletionStage unregisterForNotifications(UUri topic, SubscriptionChangeHandler handler, - CallOptions options); + CompletionStage unregisterForNotifications(UUri topic, CallOptions 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 d1328a7..b8bcb35 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 @@ -100,7 +100,7 @@ public void test_creation_of_InMemoryUSubscriptionClient_passing_only_the_transp .thenReturn(CompletableFuture.completedFuture(UStatus.newBuilder().setCode(UCode.OK).build())); assertDoesNotThrow(() -> { - InMemoryUSubscriptionClient subscriber = new InMemoryUSubscriptionClient(transport); + new InMemoryUSubscriptionClient(transport); }); verify(transport, times(2)).getSource(); @@ -112,7 +112,7 @@ public void test_creation_of_InMemoryUSubscriptionClient_passing_only_the_transp @DisplayName("Testing creation of InMemoryUSubscriptionClient passing null for the transport") public void test_creation_of_InMemoryUSubscriptionClient_passing_null_for_the_transport() { assertThrows(NullPointerException.class, () -> { - InMemoryUSubscriptionClient subscriber = new InMemoryUSubscriptionClient(null); + new InMemoryUSubscriptionClient(null); }); } @@ -902,15 +902,6 @@ void test_unregisterListener_api_for_the_happy_path() { InMemoryUSubscriptionClient subscriber = new InMemoryUSubscriptionClient(transport, rpcClient, notifier); assertNotNull(subscriber); - - SubscriptionChangeHandler handler = new SubscriptionChangeHandler() { - @Override - public void handleSubscriptionChange(UUri topic, SubscriptionStatus status) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'handleSubscriptionChange'"); - } - }; - UListener listener = new UListener() { @Override public void onReceive(UMessage message) { @@ -1113,7 +1104,7 @@ public void handleSubscriptionChange(UUri topic, SubscriptionStatus status) { assertDoesNotThrow(() -> { subscriber.registerForNotifications(topic, handler).toCompletableFuture().get(); - subscriber.unregisterForNotifications(topic, handler).toCompletableFuture().get(); + subscriber.unregisterForNotifications(topic).toCompletableFuture().get(); }); verify(notifier, times(1)).registerNotificationListener(any(), any()); @@ -1129,16 +1120,8 @@ void test_unregisterNotification_api_when_passed_a_null_topic() { InMemoryUSubscriptionClient subscriber = new InMemoryUSubscriptionClient(transport, rpcClient, notifier); assertNotNull(subscriber); - SubscriptionChangeHandler handler = new SubscriptionChangeHandler() { - @Override - public void handleSubscriptionChange(UUri topic, SubscriptionStatus status) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'handleSubscriptionChange'"); - } - }; - - assertThrows(NullPointerException.class, () -> { - subscriber.unregisterForNotifications(null, handler); + assertThrows(NullPointerException.class, () -> { + subscriber.unregisterForNotifications(null); }); verify(notifier, times(1)).registerNotificationListener(any(), any()); @@ -1176,17 +1159,10 @@ void test_calling_unregisterNotification_api_when_we_never_registered_the_notifi InMemoryUSubscriptionClient subscriber = new InMemoryUSubscriptionClient(transport, rpcClient, notifier); assertNotNull(subscriber); - SubscriptionChangeHandler handler = new SubscriptionChangeHandler() { - @Override - public void handleSubscriptionChange(UUri topic, SubscriptionStatus status) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'handleSubscriptionChange'"); - } - }; UUri topic = UUri.newBuilder(transport.getSource()).setResourceId(0x8000).build(); assertDoesNotThrow(() -> { - CompletionStage response = subscriber.unregisterForNotifications(topic, handler); + CompletionStage response = subscriber.unregisterForNotifications(topic); assertTrue(response.toCompletableFuture().isCompletedExceptionally()); response.handle((r, e) -> {