@Test public void testFilterChallenges() throws Exception { when(mockContext.getMethod()).thenReturn("POST"); when(mockAccessControlService.getAccessModes(any(IRI.class), any(Session.class))).thenReturn(emptySet()); final WebAcFilter filter = new WebAcFilter(mockAccessControlService, asList("Foo", "Bar"), "my-realm"); final List<Object> challenges = assertThrows(NotAuthorizedException.class, () -> filter.filter(mockContext), "No auth exception thrown with no access modes!").getChallenges(); assertTrue(challenges.contains("Foo realm=\"my-realm\""), "Foo not among challenges!"); assertTrue(challenges.contains("Bar realm=\"my-realm\""), "Bar not among challenges!"); } }