Skip to content

Commit

Permalink
Remove SubscriptionChangeHandler from unregisterForNotifications
Browse files Browse the repository at this point in the history
The passed handler is not used or needed so removing this attribute.

#177
  • Loading branch information
czfdcn committed Aug 7, 2024
1 parent 0bfecc6 commit b27e803
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,15 @@ public CompletionStage<NotificationsResponse> 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
* {@link UStatus} with the reason for the failure. {@link UCode.PERMISSION_DENIED} is
* returned if the topic ue_id does not equal the callers ue_id.
*/
@Override
public CompletionStage<NotificationsResponse> unregisterForNotifications(UUri topic,
SubscriptionChangeHandler handler, CallOptions options) {
public CompletionStage<NotificationsResponse> unregisterForNotifications(UUri topic, CallOptions options) {
Objects.requireNonNull(topic, "Topic missing");
Objects.requireNonNull(handler, "Handler missing");
Objects.requireNonNull(options, "CallOptions missing");

NotificationsRequest request = NotificationsRequest.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,25 @@ CompletionStage<NotificationsResponse> 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<NotificationsResponse> unregisterForNotifications(UUri topic,
SubscriptionChangeHandler handler) {
return unregisterForNotifications(topic, handler, CallOptions.DEFAULT);
default CompletionStage<NotificationsResponse> unregisterForNotifications(UUri topic) {
return unregisterForNotifications(topic, CallOptions.DEFAULT);
}


/**
* 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<NotificationsResponse> unregisterForNotifications(UUri topic, SubscriptionChangeHandler handler,
CallOptions options);
CompletionStage<NotificationsResponse> unregisterForNotifications(UUri topic, CallOptions options);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
});
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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<NotificationsResponse> response = subscriber.unregisterForNotifications(topic, handler);
CompletionStage<NotificationsResponse> response = subscriber.unregisterForNotifications(topic);
assertTrue(response.toCompletableFuture().isCompletedExceptionally());

response.handle((r, e) -> {
Expand Down

0 comments on commit b27e803

Please sign in to comment.