SubscriptionManager { public synchronized Set<Subscription> retrieveSubscriptionsByTopic(String topic) { return topicsSubscriptions.get(topic); } private  SubscriptionManager(); static SubscriptionManager getInstance(); synchronized Set<Subscription> retrieveSubscriptionsByTopic(String topic); synchronized Map<Long, Subscription> retrieveSubscriptionsByToken(String clientSessionToken); synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId,
			String topic, Ack ackMode); synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId); synchronized boolean removeSubscriptions(String clientSessionToken);  }
@Test public void testRetrieveSubscriptionsByTopic() throws Exception { Subscription expectedSubscription = new Subscription(null, SUBSCRIPTION_ID, TOPIC, ACK); Map<Long, Subscription> expectedSubscriptions = new HashMap<Long, Subscription>(); expectedSubscriptions.put(SUBSCRIPTION_ID, expectedSubscription); Map<Long, Subscription> subscriptions = subscriptionManager.retrieveSubscriptionsByToken(SESSION); assertTrue(subscriptions.size() > 0); assertEquals(expectedSubscriptions, subscriptions); }
@Test public void testRetrieveSubscriptionsByToken_null() throws Exception { assertNull(subscriptionManager.retrieveSubscriptionsByTopic(null)); }
@Test public void testRetrieveSubscriptionsByToken_not_found() throws Exception { assertNull(subscriptionManager.retrieveSubscriptionsByTopic("unknown")); }