### Question:
HierarchicalPathBasedKeycloakConfigResolver extends PathBasedKeycloakConfigResolver { @Override public KeycloakDeployment resolve(OIDCHttpFacade.Request request) { URI uri = URI.create(request.getURI()); String path = uri.getPath(); if (path != null) { while (path.startsWith("/")) { path = path.substring(1); } String[] segments = path.split("/"); List<String> paths = collectPaths(segments); for (String pathFragment: paths) { KeycloakDeployment cachedDeployment = super.getCachedDeployment(pathFragment); if (cachedDeployment != null) { return cachedDeployment; } } } throw new IllegalStateException("Can't find Keycloak configuration related to URI path " + uri); } HierarchicalPathBasedKeycloakConfigResolver(); @Override KeycloakDeployment resolve(OIDCHttpFacade.Request request);  }### Answer:
@Test public void genericAndSpecificConfigurations() throws Exception { HierarchicalPathBasedKeycloakConfigResolver resolver = new HierarchicalPathBasedKeycloakConfigResolver(); populate(resolver, true); assertThat(resolver.resolve(new MockRequest("http: assertThat(resolver.resolve(new MockRequest("http: assertThat(resolver.resolve(new MockRequest("http: assertThat(resolver.resolve(new MockRequest("http: assertThat(resolver.resolve(new MockRequest("http: assertThat(resolver.resolve(new MockRequest("http: populate(resolver, false); try { resolver.resolve(new MockRequest("http: fail("Expected java.lang.IllegalStateException: Can't find Keycloak configuration ..."); } catch (IllegalStateException expected) { } }