title: Unit testing for rest call
body: <p>I am currently at a loss with unit testing a method that calls a REST service within it for messaging a status to this service.</p>
  
  <p>I have a method like:</p>
  
  <pre><code>public void informService(String state, BusinessObject bus) {
  
    Client client = null;
    Response response = null;
    try {
  
      client = new ResteasyClientBuilder()
                              .establishConnectionTimeout(10L, TimeUnit.MINUTES)
                              .socketTimeout(10L, TimeUnit.MINUTES)
                              .build();
  
        WebTarget target = client.target("my.url");
  
        MyDTO dto = new MyDTO();
        dto.state = state;
  
        response = target.request("application/json").put(Entity.json(dto));
  
        boolean ok = handleReturnCode(response.getStatus(), bus.getId());
  
        if (!ok) {
          throw new RuntimeException("Invalid status" + response.getStatus());
        }
  
        return ok;
  
    } catch (Exception e) {
    } finally {
      try {
        if (response != null) {
          response.close();
        }
        if (client != null)
          client.close();
      } catch (Exception e) {
    }
  }
  </code></pre>
  
  <p>So in the method there is a call to a REST service which is evaluated within the method. How can I unit test this behaviour?</p>