SessionManager { public void linkWsToHttp(Session ws, String httpid) { if(ws != null && httpid != null) { Collection<Session> wss = getValidSessionsElseRemove(httpid, ISOPEN); wss.add(ws); wsid_httpid.put(ws.getId(), httpid); httpid_wss.put(httpid, wss); } }  void linkWsToHttp(Session ws, String httpid); void unlinkWs(String wsid); Collection<Session> getUserSessions(String httpid);  }
@Test public void testLinkWsToHttp() { System.out.println("linkWsToHttp"); Session ws = getMockWs(); when(ws.getId()).thenReturn("WSID"); String httpid = "HTTPID"; Collection wss = mock(Collection.class); doReturn(wss).when(instance).getValidSessionsElseRemove(eq(httpid), any(Predicate.class)); instance.linkWsToHttp(ws, httpid); verify(wss).add(eq(ws)); verify(wsid_httpid).put(eq("WSID"), eq("HTTPID")); verify(httpid_wss).put(eq("HTTPID"), eq(wss)); }