title: Mocking method with javax.ws.rs.core.Response and assertion
body: <p>I have a main method that implements/calls another method. I'm writing a test case for the main method where I have to mock the response of the calling method.</p>
  
  <pre><code>public String getAccount(String add, String sub) {
  ...
  Response r = getService(add, sub);
  ...
  }
  
  public Response getName(String add, String sub) {
  ...
  Response r = WebTarget.path(pathString).queryParam("aaa", "xxxx").queryParam("byId", add)
              .request().header("accept", "json")
              .header("Authorization",token).get();
  return r;
  }
  </code></pre>
  
  <p>I'm trying to write a test case here so that I can mock the response of getName to return non-200 response.</p>
  
  <pre><code>@Test
  public void testGetAccount(){
  when(getName).thenReturn(...);//How do I mock this?
  String result = getAccount(anyString, anyString);
  assertNotEqual(Https.Ok);
  }
  </code></pre>
  
  <p>How do I mock the response of getName method here?</p>