@Test public void configure() throws MalformedURLException, ExecutionException, InterruptedException { interceptor.addRule() .url(BASE_URL + ModelServerPaths.SERVER_CONFIGURE) .put() .respond(JsonResponse.success().toString()); ModelServerClient client = createClient(); final CompletableFuture<Response<Boolean>> f = client.configure(() -> "/home/user/workspace"); assertThat(f.get().body(), equalTo(true)); }
@Override public CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration) { ObjectNode config = Json.object( Json.prop("workspaceRoot", Json.text(configuration.getWorkspaceRoot()))); final Request request = new Request.Builder() .url(makeUrl(SERVER_CONFIGURE)) .put(RequestBody.create(config.toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "type")) .thenApply(this::getBodyOrThrow) .thenApply(response -> response.mapBody(body -> body.equals("success"))); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration) { ObjectNode config = Json.object( Json.prop("workspaceRoot", Json.text(configuration.getWorkspaceRoot()))); final Request request = new Request.Builder() .url(makeUrl(SERVER_CONFIGURE)) .put(RequestBody.create(config.toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "type")) .thenApply(this::getBodyOrThrow) .thenApply(response -> response.mapBody(body -> body.equals("success"))); } }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration) { ObjectNode config = Json.object( Json.prop("workspaceRoot", Json.text(configuration.getWorkspaceRoot()))); final Request request = new Request.Builder() .url(makeUrl(SERVER_CONFIGURE)) .put(RequestBody.create(config.toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "type")) .thenApply(this::getBodyOrThrow) .thenApply(response -> response.mapBody(body -> body.equals("success"))); } ModelServerClient(final String baseUrl);  ModelServerClient(final OkHttpClient client, final String baseUrl); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration) { ObjectNode config = Json.object( Json.prop("workspaceRoot", Json.text(configuration.getWorkspaceRoot()))); final Request request = new Request.Builder() .url(makeUrl(SERVER_CONFIGURE)) .put(RequestBody.create(config.toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "type")) .thenApply(this::getBodyOrThrow) .thenApply(response -> response.mapBody(body -> body.equals("success"))); } ModelServerClient(final String baseUrl);  ModelServerClient(final OkHttpClient client, final String baseUrl); void close(); @Override CompletableFuture<Response<String>> get(final String modelUri); @Override CompletableFuture<Response<EObject>> get(final String modelUri, final String format); @Override CompletableFuture<Response<List<String>>> getAll(); @Override CompletableFuture<Response<Boolean>> delete(final String modelUri); @Override CompletableFuture<Response<String>> update(final String modelUri, final String updatedModel); @Override CompletableFuture<Response<EObject>> update(final String modelUri, final EObject updatedModel,
      final String format); @Override CompletableFuture<Response<Boolean>> save(final String modelUri); @Override CompletableFuture<Response<String>> getSchema(final String modelUri); @Override CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration); @Override CompletableFuture<Response<Boolean>> ping(); @Override CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command); @Override CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command, final String format); @Override CompletableFuture<Response<Boolean>> edit(final String modelUri, final CCommand command,
      final String format); @Override void subscribe(final String modelUri, final SubscriptionListener subscriptionListener, final String format); @Override boolean unsubscribe(final String modelUri); String encode(final EObject eObject); String encode(final EObject eObject, final String format); Optional<EObject> decode(final String payload); Optional<EObject> decode(final String payload, final String format); @Override EditingContext edit(); @Override boolean close(final EditingContext editingContext); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration) { ObjectNode config = Json.object( Json.prop("workspaceRoot", Json.text(configuration.getWorkspaceRoot()))); final Request request = new Request.Builder() .url(makeUrl(SERVER_CONFIGURE)) .put(RequestBody.create(config.toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "type")) .thenApply(this::getBodyOrThrow) .thenApply(response -> response.mapBody(body -> body.equals("success"))); } ModelServerClient(final String baseUrl);  ModelServerClient(final OkHttpClient client, final String baseUrl); void close(); @Override CompletableFuture<Response<String>> get(final String modelUri); @Override CompletableFuture<Response<EObject>> get(final String modelUri, final String format); @Override CompletableFuture<Response<List<String>>> getAll(); @Override CompletableFuture<Response<Boolean>> delete(final String modelUri); @Override CompletableFuture<Response<String>> update(final String modelUri, final String updatedModel); @Override CompletableFuture<Response<EObject>> update(final String modelUri, final EObject updatedModel,
      final String format); @Override CompletableFuture<Response<Boolean>> save(final String modelUri); @Override CompletableFuture<Response<String>> getSchema(final String modelUri); @Override CompletableFuture<Response<Boolean>> configure(final ServerConfiguration configuration); @Override CompletableFuture<Response<Boolean>> ping(); @Override CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command); @Override CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command, final String format); @Override CompletableFuture<Response<Boolean>> edit(final String modelUri, final CCommand command,
      final String format); @Override void subscribe(final String modelUri, final SubscriptionListener subscriptionListener, final String format); @Override boolean unsubscribe(final String modelUri); String encode(final EObject eObject); String encode(final EObject eObject, final String format); Optional<EObject> decode(final String payload); Optional<EObject> decode(final String payload, final String format); @Override EditingContext edit(); @Override boolean close(final EditingContext editingContext);  }