EventSourceTopology implements EventAggregatorService, EventSourceRegistry { public void unRegister(final EventSource eventSource) { final NodeKey nodeKey = eventSource.getSourceNodeKey(); final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey); final Registration removeRegistration = routedRpcRegistrations.remove(nodeKey); if (removeRegistration != null) { removeRegistration.close(); remove(sourcePath); } } EventSourceTopology(final DataBroker dataBroker, final RpcProviderService providerService,
            RpcConsumerRegistry rpcService); @Override ListenableFuture<RpcResult<CreateTopicOutput>> createTopic(final CreateTopicInput input); @Override ListenableFuture<RpcResult<DestroyTopicOutput>> destroyTopic(final DestroyTopicInput input); @Override void close(); void register(final EventSource eventSource); void unRegister(final EventSource eventSource); @Override EventSourceRegistration<T> registerEventSource(final T eventSource);  }
@Test public void unregisterTest() throws Exception { topicTestHelper(); EventSource eventSourceMock = mock(EventSource.class); NodeId nodeId = new NodeId("nodeIdValue1"); NodeKey nodeKey = new NodeKey(nodeId); Map<NodeKey, Registration> localMap = eventSourceTopology.getRoutedRpcRegistrations(); NodeKey nodeKeyMock = mock(NodeKey.class); doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey(); ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class); localMap.put(nodeKeyMock, routedRpcRegistrationMock); eventSourceTopology.unRegister(eventSourceMock); verify(routedRpcRegistrationMock, times(1)).close(); }