TopicManagerImpl implements TopicManager { int removeSessionToSessions(Session session, Collection<Session> sessions) { if (sessions != null) { if (sessions.remove(session)) { return 1; } } return 0; }  @Override Map<String, Collection<Session>> getSessionsByTopic(); @Override int registerTopicSession(String topic, Session session); @Override int unregisterTopicSession(String topic, Session session); @Override Collection<String> removeSessionsToTopic(Collection<Session> sessions); @Override Collection<String> removeSessionToTopics(Session session); @Override Collection<Session> getSessionsForTopic(String topic); @Override int getNumberSubscribers(String topic);  }
@Test public void testRemoveSessionToSessions() { System.out.println("removeSessionToSessions"); Session session = mock(Session.class); Collection<Session> sessions = new ArrayList<>(); sessions.add(session); int result = instance.removeSessionToSessions(session, null); assertThat(result).isEqualTo(0); result = instance.removeSessionToSessions(session, Collections.EMPTY_LIST); assertThat(result).isEqualTo(0); result = instance.removeSessionToSessions(session, sessions); assertThat(result).isEqualTo(1); assertThat(sessions).isEmpty(); result = instance.removeSessionToSessions(session, sessions); assertThat(result).isEqualTo(0); assertThat(sessions).isEmpty(); sessions.add(session); sessions.add(mock(Session.class)); result = instance.removeSessionToSessions(session, sessions); assertThat(result).isEqualTo(1); assertThat(sessions).hasSize(1); }