@Test(expected = NullPointerException.class) public void testAddSubscription_topic_null() throws Exception { subscriptionManager.addSubscription(null, SESSION, SUBSCRIPTION_ID, null, ACK); }
public synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId, String topic, Ack ackMode) { if (clientSessionToken == null || clientSessionToken.isEmpty()) throw new NullPointerException("clientSessionToken can't be null nor empty"); if (subscriptionId == null) throw new NullPointerException("subscriptionId can't be null"); if (topic == null || clientSessionToken.isEmpty()) throw new NullPointerException("topic can't be null nor empty"); Subscription subscription = new Subscription(channel, subscriptionId, topic, ackMode); Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { clientSubscriptions = new HashMap<Long, Subscription>(); clientsSubscriptions.put(clientSessionToken, clientSubscriptions); } clientSubscriptions.put(subscriptionId, subscription); Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(topic); if (topicSubscriptions == null) { topicSubscriptions = new TreeSet<Subscription>(); topicsSubscriptions.put(topic, topicSubscriptions); } topicSubscriptions.add(subscription); return subscription; }
SubscriptionManager { public synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId, String topic, Ack ackMode) { if (clientSessionToken == null || clientSessionToken.isEmpty()) throw new NullPointerException("clientSessionToken can't be null nor empty"); if (subscriptionId == null) throw new NullPointerException("subscriptionId can't be null"); if (topic == null || clientSessionToken.isEmpty()) throw new NullPointerException("topic can't be null nor empty"); Subscription subscription = new Subscription(channel, subscriptionId, topic, ackMode); Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { clientSubscriptions = new HashMap<Long, Subscription>(); clientsSubscriptions.put(clientSessionToken, clientSubscriptions); } clientSubscriptions.put(subscriptionId, subscription); Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(topic); if (topicSubscriptions == null) { topicSubscriptions = new TreeSet<Subscription>(); topicsSubscriptions.put(topic, topicSubscriptions); } topicSubscriptions.add(subscription); return subscription; } }
SubscriptionManager { public synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId, String topic, Ack ackMode) { if (clientSessionToken == null || clientSessionToken.isEmpty()) throw new NullPointerException("clientSessionToken can't be null nor empty"); if (subscriptionId == null) throw new NullPointerException("subscriptionId can't be null"); if (topic == null || clientSessionToken.isEmpty()) throw new NullPointerException("topic can't be null nor empty"); Subscription subscription = new Subscription(channel, subscriptionId, topic, ackMode); Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { clientSubscriptions = new HashMap<Long, Subscription>(); clientsSubscriptions.put(clientSessionToken, clientSubscriptions); } clientSubscriptions.put(subscriptionId, subscription); Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(topic); if (topicSubscriptions == null) { topicSubscriptions = new TreeSet<Subscription>(); topicsSubscriptions.put(topic, topicSubscriptions); } topicSubscriptions.add(subscription); return subscription; } private  SubscriptionManager(); }
SubscriptionManager { public synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId, String topic, Ack ackMode) { if (clientSessionToken == null || clientSessionToken.isEmpty()) throw new NullPointerException("clientSessionToken can't be null nor empty"); if (subscriptionId == null) throw new NullPointerException("subscriptionId can't be null"); if (topic == null || clientSessionToken.isEmpty()) throw new NullPointerException("topic can't be null nor empty"); Subscription subscription = new Subscription(channel, subscriptionId, topic, ackMode); Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { clientSubscriptions = new HashMap<Long, Subscription>(); clientsSubscriptions.put(clientSessionToken, clientSubscriptions); } clientSubscriptions.put(subscriptionId, subscription); Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(topic); if (topicSubscriptions == null) { topicSubscriptions = new TreeSet<Subscription>(); topicsSubscriptions.put(topic, topicSubscriptions); } topicSubscriptions.add(subscription); return subscription; } 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); }
SubscriptionManager { public synchronized Subscription addSubscription(Channel channel, String clientSessionToken, Long subscriptionId, String topic, Ack ackMode) { if (clientSessionToken == null || clientSessionToken.isEmpty()) throw new NullPointerException("clientSessionToken can't be null nor empty"); if (subscriptionId == null) throw new NullPointerException("subscriptionId can't be null"); if (topic == null || clientSessionToken.isEmpty()) throw new NullPointerException("topic can't be null nor empty"); Subscription subscription = new Subscription(channel, subscriptionId, topic, ackMode); Map<Long, Subscription> clientSubscriptions = retrieveSubscriptionsByToken(clientSessionToken); if (clientSubscriptions == null) { clientSubscriptions = new HashMap<Long, Subscription>(); clientsSubscriptions.put(clientSessionToken, clientSubscriptions); } clientSubscriptions.put(subscriptionId, subscription); Set<Subscription> topicSubscriptions = retrieveSubscriptionsByTopic(topic); if (topicSubscriptions == null) { topicSubscriptions = new TreeSet<Subscription>(); topicsSubscriptions.put(topic, topicSubscriptions); } topicSubscriptions.add(subscription); return subscription; } 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);  }