@Test
public void shouldUpdateWorkflowState() throws Exception {

  final WorkflowState workflowState = WorkflowState.builder()
      .enabled(true)
      .nextNaturalTrigger(Instant.parse("2017-01-03T21:00:00Z"))
      .nextNaturalTrigger(Instant.parse("2017-01-03T22:00:00Z"))
      .build();
  when(client.send(any(Request.class))).thenReturn(CompletableFuture.completedFuture(
      response(HTTP_OK, workflowState)));
  final CompletableFuture<WorkflowState> r =
      styx.updateWorkflowState("f[ ]o-cmp", "bar-w[f]", workflowState).toCompletableFuture();
  verify(client, timeout(30_000)).send(requestCaptor.capture());
  assertThat(r.isDone(), is(true));
  final Request request = requestCaptor.getValue();
  assertThat(request.url().toString(), is(API_URL + "/workflows/f%5B%20%5Do-cmp/bar-w%5Bf%5D/state"));
  assertThat(Json.deserialize(bytesOfRequestBody(request), WorkflowState.class), is(workflowState));
  assertThat(request.method(), is("PATCH"));
}