@Test public void showsEnabledAndDisabledPlugins() { NamedPlugin one = namedPlugin("one", PASS_THROUGH); NamedPlugin two = namedPlugin("two", PASS_THROUGH); NamedPlugin three = namedPlugin("three", PASS_THROUGH); NamedPlugin four = namedPlugin("four", PASS_THROUGH); two.setEnabled(false); three.setEnabled(false); List<NamedPlugin> plugins = asList(one, two, three, four); PluginListHandler handler = new PluginListHandler(plugins); HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block(); assertThat(response.status(), is(OK)); assertThat(response.bodyAs(UTF_8), is("" + "<h3>Enabled</h3>" + "<a href='/admin/plugins/one'>one</a><br />" + "<a href='/admin/plugins/four'>four</a><br />" + "<h3>Disabled</h3>" + "<a href='/admin/plugins/two'>two</a><br />" + "<a href='/admin/plugins/three'>three</a><br />")); }
@Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { Stream<NamedPlugin> enabled = plugins.stream().filter(NamedPlugin::enabled); Stream<NamedPlugin> disabled = plugins.stream().filter(plugin -> !plugin.enabled()); boolean needsIncludeDisabledPlugins = existDisabledPlugins(); String output = section(needsIncludeDisabledPlugins ? "Enabled" : "Loaded", enabled) + (needsIncludeDisabledPlugins ? section("Disabled", disabled) : ""); return Eventual.of(response(OK) .body(output, UTF_8) .addHeader(CONTENT_TYPE, HTML_UTF_8.toString()) .build()); }
PluginListHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { Stream<NamedPlugin> enabled = plugins.stream().filter(NamedPlugin::enabled); Stream<NamedPlugin> disabled = plugins.stream().filter(plugin -> !plugin.enabled()); boolean needsIncludeDisabledPlugins = existDisabledPlugins(); String output = section(needsIncludeDisabledPlugins ? "Enabled" : "Loaded", enabled) + (needsIncludeDisabledPlugins ? section("Disabled", disabled) : ""); return Eventual.of(response(OK) .body(output, UTF_8) .addHeader(CONTENT_TYPE, HTML_UTF_8.toString()) .build()); } }
PluginListHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { Stream<NamedPlugin> enabled = plugins.stream().filter(NamedPlugin::enabled); Stream<NamedPlugin> disabled = plugins.stream().filter(plugin -> !plugin.enabled()); boolean needsIncludeDisabledPlugins = existDisabledPlugins(); String output = section(needsIncludeDisabledPlugins ? "Enabled" : "Loaded", enabled) + (needsIncludeDisabledPlugins ? section("Disabled", disabled) : ""); return Eventual.of(response(OK) .body(output, UTF_8) .addHeader(CONTENT_TYPE, HTML_UTF_8.toString()) .build()); } PluginListHandler(List<NamedPlugin> plugins); }
PluginListHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { Stream<NamedPlugin> enabled = plugins.stream().filter(NamedPlugin::enabled); Stream<NamedPlugin> disabled = plugins.stream().filter(plugin -> !plugin.enabled()); boolean needsIncludeDisabledPlugins = existDisabledPlugins(); String output = section(needsIncludeDisabledPlugins ? "Enabled" : "Loaded", enabled) + (needsIncludeDisabledPlugins ? section("Disabled", disabled) : ""); return Eventual.of(response(OK) .body(output, UTF_8) .addHeader(CONTENT_TYPE, HTML_UTF_8.toString()) .build()); } PluginListHandler(List<NamedPlugin> plugins); @Override Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context); }
PluginListHandler implements WebServiceHandler { @Override public Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context) { Stream<NamedPlugin> enabled = plugins.stream().filter(NamedPlugin::enabled); Stream<NamedPlugin> disabled = plugins.stream().filter(plugin -> !plugin.enabled()); boolean needsIncludeDisabledPlugins = existDisabledPlugins(); String output = section(needsIncludeDisabledPlugins ? "Enabled" : "Loaded", enabled) + (needsIncludeDisabledPlugins ? section("Disabled", disabled) : ""); return Eventual.of(response(OK) .body(output, UTF_8) .addHeader(CONTENT_TYPE, HTML_UTF_8.toString()) .build()); } PluginListHandler(List<NamedPlugin> plugins); @Override Eventual<HttpResponse> handle(HttpRequest request, HttpInterceptor.Context context);  }