@Test @SuppressWarnings({ "checkstyle:ThrowsCount" }) public void edit() throws EncodingException, ExecutionException, InterruptedException, MalformedURLException { Workflow flow = CoffeeFactory.eINSTANCE.createWorkflow(); ((InternalEObject) flow).eSetProxyURI(URI.createURI("SuperBrewer3000.json# CCommand add = CCommandFactory.eINSTANCE.createCommand(); add.setType(CommandKind.ADD); add.setOwner(flow); add.setFeature("nodes"); add.getObjectsToAdd().add(CoffeeFactory.eINSTANCE.createAutomaticTask()); add.getObjectValues().addAll(add.getObjectsToAdd()); JsonResource cmdRes = new JsonResource(URI.createURI("$command.json")); cmdRes.getContents().add(add); final JsonNode expected = jsonCodec.encode(add); cmdRes.getContents().clear(); assertThat(expected.toString(), containsString("\"type\":\"add\"")); assertThat(expected.toString(), containsString("\"objectValues\":[{\"eClass\":")); interceptor.addRule().url(BASE_URL + ModelServerPaths.EDIT + "?modeluri=" + "SuperBrewer3000.json&format=json") .patch().answer(request -> { Buffer buffer = new Buffer(); try { request.body().writeTo(buffer); } catch (IOException e) { e.printStackTrace(); fail("Failed to capture request body content: " + e.getMessage()); } String body = buffer.readString(Charsets.UTF_8).replace("\\\\", "\\").replace("\\\"", "\""); if (body.contains(expected.toString())) { return new Rule.Builder().respond(JsonResponse.success("confirmed").toString()); } return new Rule.Builder().respond(JsonResponse.error().toString()); }); ModelServerClient client = createClient(); final CompletableFuture<Response<Boolean>> f = client.edit("SuperBrewer3000.json", add, "json"); assertThat(f.get().body(), is(true)); }
@Override public CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command) { return edit(modelUri, command, "json"); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command) { return edit(modelUri, command, "json"); } }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command) { return edit(modelUri, command, "json"); } ModelServerClient(final String baseUrl);  ModelServerClient(final OkHttpClient client, final String baseUrl); }
ModelServerClient implements ModelServerClientApi<EObject>, ModelServerPaths { @Override public CompletableFuture<Response<Boolean>> edit(final String modelUri, final Command command) { return edit(modelUri, command, "json"); } 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>> edit(final String modelUri, final Command command) { return edit(modelUri, command, "json"); } 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);  }