MessageControllerManager { public JsTopicMessageController getJsTopicMessageController(String topic) { logger.debug("Looking for messageController for topic '{}'", topic); JsTopicMessageController messageController = messageControllerCache.loadFromCache(topic); if(null == messageController) { messageController = getJsTopicMessageControllerFromJsTopicControl(topic); if(null == messageController) { messageController = getJsTopicMessageControllerFromJsTopicControls(topic); if(null == messageController) { messageController = new DefaultJsTopicMessageController(); } } messageControllerCache.saveToCache(topic, messageController.getClass()); } return messageController; }  JsTopicMessageController getJsTopicMessageController(String topic);  }
@Test public void getJsTopicMessageControllerTestFromCache() { System.out.println("GetJsTopicMessageController"); JsTopicMessageController jtmc = mock(JsTopicMessageController.class); when(messageControllerCache.loadFromCache(eq(TOPIC))).thenReturn(jtmc); JsTopicMessageController result = instance.getJsTopicMessageController(TOPIC); assertThat(result).isEqualTo(jtmc); verify(messageControllerCache, never()).saveToCache(eq(TOPIC), any(Class.class)); }