URLResponse { public URLResponse(final String tableauUrl, final Path path, final String workbook) throws Exception { this._url = new URL(tableauUrl + "/" + path.getPath() + workbook); refreshContents(); } URLResponse(final String tableauUrl, final Path path, final String workbook); void refreshContents(); String getContents(); boolean indicatesSuccess(); boolean indicatesError();  }
@Test public void testURLResponse() throws Exception { final URLResponse urlResponse = mock(URLResponse.class); doNothing().when(urlResponse).refreshContents(); when(urlResponse.indicatesSuccess()).thenCallRealMethod(); when(urlResponse.indicatesError()).thenCallRealMethod(); doCallRealMethod().when(urlResponse).setURLContents(anyString()); urlResponse.setURLContents("Success"); assertThat(urlResponse.indicatesSuccess()).isTrue(); assertThat(urlResponse.indicatesError()).isFalse(); urlResponse.setURLContents("Error"); assertThat(urlResponse.indicatesError()).isTrue(); assertThat(urlResponse.indicatesSuccess()).isFalse(); }