UserContextFactory { public UserContext getUserContext(String wsid) { if(containsKey(wsid)) { return map.get(wsid); } return null; }  void createUserContext(HandshakeRequest request, String wsid); void destroyUserContext(String wsid); UserContext getUserContext(String wsid);  }
@Test public void testGetUserContext() { System.out.println("getUserContext"); UserContext uc = mock(UserContext.class); instance.getMap().put("ID1", uc); doReturn(true).when(instance).containsKey(eq("ID1")); doReturn(false).when(instance).containsKey(eq("ID2")); UserContext result = instance.getUserContext("ID1"); assertThat(result).isNotNull(); result = instance.getUserContext("ID2"); assertThat(result).isNull(); }