### Question:
SubscriptionService implements SubscriptionManager { @Override public void unsubscribe(URI id) throws ResponseException { Subscription removedSub; synchronized (subscriptionId2Subscription) { removedSub = this.subscriptionId2Subscription.remove(id.toString()); } if (removedSub == null) { throw new ResponseException(ErrorType.NotFound); } synchronized (subscriptionId2Context) { this.subscriptionId2Context.removeAll(id.toString()); } intervalHandlerREST.removeSub(id.toString()); intervalHandlerMQTT.removeSub(id.toString()); List<EntityInfo> entities = removedSub.getEntities(); if (entities == null || entities.isEmpty()) { synchronized (type2EntitiesSubscriptions) { type2EntitiesSubscriptions.remove(ALL_TYPES_TYPE, removedSub); } } else { for (EntityInfo info : entities) { synchronized (type2EntitiesSubscriptions) { type2EntitiesSubscriptions.remove(info.getType(), removedSub); } } } TimerTask task = subId2TimerTask.get(id.toString()); if (task != null) { task.cancel(); } new Thread() { public void run() { synchronized (subscriptionStore) { subscriptionStore.remove(id.toString()); } }; }.start(); } SubscriptionService(); @Override URI subscribe(SubscriptionRequest subscriptionRequest); @Override void unsubscribe(URI id); @Override Subscription updateSubscription(SubscriptionRequest subscriptionRequest); @Override List<Subscription> getAllSubscriptions(int limit); @Override Subscription getSubscription(String subscriptionId); @KafkaListener(topics = "${entity.create.topic}", groupId = "submanager") void handleCreate(Message<byte[]> message); @KafkaListener(topics = "${entity.update.topic}", groupId = "submanager") void handleUpdate(Message<byte[]> message); @KafkaListener(topics = "${entity.append.topic}", groupId = "submanager") void handleAppend(Message<byte[]> message); @KafkaListener(topics = "${entity.delete.topic}", groupId = "submanager") void handleDelete(Message<byte[]> message); @KafkaListener(topics = "${csource.notification.topic}", groupId = "submanager") void handleCSourceNotification(Message<byte[]> message); @Override void remoteNotify(String id, Notification notification); void reportNotification(String subId, Long now); void reportFailedNotification(String subId, Long now); void reportSuccessfulNotification(String subId, Long now);  }### Answer:
@Test public void unsubscribeTest() throws URISyntaxException, ResponseException { Subscription removedSub=new Subscription(); URI id=new URI("urn:ngsi-ld:Subscription:173223"); when(subscriptionId2Subscription.remove(any())).thenReturn(removedSub); manager.unsubscribe(id); verify(intervalNotificationHandler,times(1)).removeSub(any()); }