TopicAccessManager { boolean checkAccessTopicGlobalAC(UserContext ctx, String topic) throws IllegalAccessException { logger.debug("Looking for accessController for topic '{}' from GlobalAccess", topic); Iterable<JsTopicAccessController> accessControls = topicAccessController.select(DEFAULT_AT); return checkAccessTopicFromControllers(ctx, topic, accessControls); }  void checkAccessTopic(UserContext ctx, String topic);  }
@Test(expected = IllegalAccessException.class) public void checkAccessTopicGlobalACTest() throws IllegalAccessException { System.out.println("checkAccessTopicGlobalAC"); UserContext userContext = mock(UserContext.class); Instance instances = mock(Instance.class); when(topicAccessController.select(eq(DEFAULT_AT))).thenReturn(instances); doReturn(Boolean.FALSE).doReturn(Boolean.TRUE).doThrow(IllegalAccessException.class).when(instance).checkAccessTopicFromControllers(eq(userContext), eq(TOPIC1), eq(instances)); boolean result = instance.checkAccessTopicGlobalAC(userContext, TOPIC1); assertThat(result).isFalse(); result = instance.checkAccessTopicGlobalAC(userContext, TOPIC1); assertThat(result).isTrue(); instance.checkAccessTopicGlobalAC(userContext, TOPIC1); }