TopicAccessManager { boolean checkAccessTopicFromControllers(UserContext ctx, String topic, Iterable<JsTopicAccessController> accessControls) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' : '{}'", topic, accessControls); boolean tacPresent = false; if (null != accessControls) { for (JsTopicAccessController accessControl : accessControls) { accessControl.checkAccess(ctx, topic); tacPresent = true; } } return tacPresent; }  void checkAccessTopic(UserContext ctx, String topic);  }
@Test(expected = IllegalAccessException.class) public void checkAccessTopicFromControllersTest() throws IllegalAccessException { System.out.println("checkAccessTopicFromControllers"); UserContext userContext = mock(UserContext.class); JsTopicAccessController jtac1 = mock(JsTopicAccessController.class); Collection<JsTopicAccessController> jtacs = Arrays.asList(jtac1); doNothing().doThrow(IllegalAccessException.class).when(jtac1).checkAccess(eq(userContext), eq(TOPIC1)); boolean result = instance.checkAccessTopicFromControllers(userContext, TOPIC1, null); assertThat(result).isFalse(); result = instance.checkAccessTopicFromControllers(userContext, TOPIC1, Collections.EMPTY_LIST); assertThat(result).isFalse(); result = instance.checkAccessTopicFromControllers(userContext, TOPIC1, jtacs); assertThat(result).isTrue(); instance.checkAccessTopicFromControllers(userContext, TOPIC1, jtacs); }