@Test public void exposesNameAndStatusViaAdminInterface() throws ExecutionException, InterruptedException { DerivedStyxService service = new DerivedStyxService("derived-service", new CompletableFuture<>()); HttpResponse response = Mono.from(service.adminInterfaceHandlers().get("status").handle(get, MOCK_CONTEXT) .flatMap(r -> r.aggregate(1024))).block(); assertThat(response.bodyAs(UTF_8), is("{ name: \"derived-service\" status: \"CREATED\" }")); }
@Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .stream())); }
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .stream())); } }
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .stream())); } AbstractStyxService(String name); }
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .stream())); } AbstractStyxService(String name); StyxServiceStatus status(); @Override CompletableFuture<Void> start(); @Override CompletableFuture<Void> stop(); @Override Map<String, HttpHandler> adminInterfaceHandlers(); String serviceName(); }
AbstractStyxService implements StyxService { @Override public Map<String, HttpHandler> adminInterfaceHandlers() { return ImmutableMap.of("status", (request, context) -> Eventual.of( response(OK) .addHeader(CONTENT_TYPE, APPLICATION_JSON) .body(format("{ name: \"%s\" status: \"%s\" }", name, status), UTF_8) .build() .stream())); } AbstractStyxService(String name); StyxServiceStatus status(); @Override CompletableFuture<Void> start(); @Override CompletableFuture<Void> stop(); @Override Map<String, HttpHandler> adminInterfaceHandlers(); String serviceName();  }