JolokiaKeycloakCustomizer implements Customizer { @Override public void customize() { if (this.role == null) { return; } Consumer<Archive> keycloakPreparer = (archive) -> { archive.as(Secured.class) .protect() .withRole(this.role); }; Consumer<Archive> preparer = this.jolokia.jolokiaWarPreparer(); if (preparer == null) { preparer = keycloakPreparer; } else { preparer = preparer.andThen(keycloakPreparer); } this.jolokia.prepareJolokiaWar(preparer); }  @Override void customize();  }
@Test public void testWithoutRole() { JolokiaFraction jolokia = new JolokiaFraction(); JolokiaKeycloakCustomizer customizer = new JolokiaKeycloakCustomizer(); customizer.jolokia = jolokia; customizer.customize(); assertThat( jolokia.jolokiaWarPreparer() ).isNull(); }
@Test public void testWithRole() { JolokiaFraction jolokia = new JolokiaFraction(); JolokiaKeycloakCustomizer customizer = new JolokiaKeycloakCustomizer(); customizer.jolokia = jolokia; customizer.role = "admin"; customizer.customize(); assertThat( jolokia.jolokiaWarPreparer() ).isNotNull(); }