ApplicationStatusHandler extends AbstractRequestHandler { static JSONArray renderRequestHandlers(JdiscBindingsConfig bindingsConfig, Map<ComponentId, ? extends RequestHandler> handlersById) { JSONArray ret = new JSONArray(); for (Map.Entry<ComponentId, ? extends RequestHandler> handlerEntry : handlersById.entrySet()) { String id = handlerEntry.getKey().stringValue(); RequestHandler handler = handlerEntry.getValue(); JSONObject handlerJson = renderComponent(handler, handlerEntry.getKey()); addBindings(bindingsConfig, id, handlerJson); ret.put(handlerJson); } return ret; } @Inject  ApplicationStatusHandler(ApplicationMetadataConfig metaConfig,
                                    ApplicationUserdataConfig userConfig,
                                    JdiscBindingsConfig bindingsConfig,
                                    ComponentRegistry<ClientProvider> clientProviderRegistry,
                                    ComponentRegistry<ServerProvider> serverProviderRegistry,
                                    ComponentRegistry<RequestFilterBase> requestFilterRegistry,
                                    ComponentRegistry<ResponseFilterBase> responseFilterRegistry); @Override ContentChannel handleRequest(com.yahoo.jdisc.Request request, ResponseHandler handler);  }
@Test public void request_handlers_are_rendered() throws Exception { final String id = "myHandler"; final String serverBinding1 = "http:/anotherServerBinding"; final String clientBinding = "http: HashMap<ComponentId, RequestHandler> handlersById = new HashMap<>(); handlersById.put(new ComponentId(id), Mockito.mock(RequestHandler.class)); JdiscBindingsConfig bindingsConfig = new JdiscBindingsConfig(new JdiscBindingsConfig.Builder() .handlers(id, new Handlers.Builder() .serverBindings(serverBinding1) .serverBindings(serverBinding2) .clientBindings(clientBinding)) ); String json = ApplicationStatusHandler.renderRequestHandlers(bindingsConfig, handlersById).toString(); assertThat(json, containsString("\"" + id + "\"")); assertThat(json, containsString(serverBinding1)); assertThat(json, containsString(serverBinding2)); assertThat(json, containsString(clientBinding)); }
@Test public void client_providers_are_rendered() throws Exception { final String id = "myClient"; final String clientBinding = "http:/anotherClientBinding"; final String serverBinding = "http: HashMap<ComponentId, ClientProvider> clientsById = new HashMap<>(); clientsById.put(new ComponentId(id), Mockito.mock(ClientProvider.class)); JdiscBindingsConfig bindingsConfig = new JdiscBindingsConfig(new JdiscBindingsConfig.Builder() .handlers(id, new Handlers.Builder() .clientBindings(clientBinding) .clientBindings(clientBinding2) .serverBindings(serverBinding)) ); String json = ApplicationStatusHandler.renderRequestHandlers(bindingsConfig, clientsById).toString(); System.out.println(json); assertThat(json, containsString("\"" + id + "\"")); assertThat(json, containsString(clientBinding)); assertThat(json, containsString(clientBinding2)); assertThat(json, containsString(serverBinding)); }