@Test @SuppressWarnings({ "checkstyle:ThrowsCount" }) public void update() throws EncodingException, ExecutionException, InterruptedException, MalformedURLException { final JsonNode expected = jsonCodec.encode(display); interceptor.addRule() .url(BASE_URL + ModelServerPaths.MODEL_BASE_PATH + "?modeluri=" + "SuperBrewer3000.json") .patch() .respond(JsonResponse.success(expected).toString()); ModelServerClient client = createClient(); final CompletableFuture<Response<String>> f = client.update( "SuperBrewer3000.json", expected.toString()); assertThat(f.get().body(), equalTo(expected.toString())); }
@Override public CompletableFuture<Response<String>> update(final String modelUri, final String updatedModel) { final Request request = new Request.Builder() .url( createHttpUrlBuilder(makeUrl(MODEL_BASE_PATH)) .addQueryParameter("modeluri", modelUri) .build()) .patch( RequestBody.create( Json.object(Json.prop("data", Json.text(updatedModel))).toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "data")) .thenApply(this::getBodyOrThrow); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<String>> update(final String modelUri, final String updatedModel) { final Request request = new Request.Builder() .url( createHttpUrlBuilder(makeUrl(MODEL_BASE_PATH)) .addQueryParameter("modeluri", modelUri) .build()) .patch( RequestBody.create( Json.object(Json.prop("data", Json.text(updatedModel))).toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "data")) .thenApply(this::getBodyOrThrow); } }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<String>> update(final String modelUri, final String updatedModel) { final Request request = new Request.Builder() .url( createHttpUrlBuilder(makeUrl(MODEL_BASE_PATH)) .addQueryParameter("modeluri", modelUri) .build()) .patch( RequestBody.create( Json.object(Json.prop("data", Json.text(updatedModel))).toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "data")) .thenApply(this::getBodyOrThrow); } ModelServerClient(final String baseUrl);  ModelServerClient(final OkHttpClient client, final String baseUrl); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<String>> update(final String modelUri, final String updatedModel) { final Request request = new Request.Builder() .url( createHttpUrlBuilder(makeUrl(MODEL_BASE_PATH)) .addQueryParameter("modeluri", modelUri) .build()) .patch( RequestBody.create( Json.object(Json.prop("data", Json.text(updatedModel))).toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "data")) .thenApply(this::getBodyOrThrow); } 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<String>> update(final String modelUri, final String updatedModel) { final Request request = new Request.Builder() .url( createHttpUrlBuilder(makeUrl(MODEL_BASE_PATH)) .addQueryParameter("modeluri", modelUri) .build()) .patch( RequestBody.create( Json.object(Json.prop("data", Json.text(updatedModel))).toString(), MediaType.parse("application/json"))) .build(); return makeCall(request) .thenApply(response -> parseField(response, "data")) .thenApply(this::getBodyOrThrow); } 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);  }