BaseClient { public TaskResource executeMonitorableRequest(Request request) { this.validateNotNullArguments(request); String response = this.executeRequest(request); TaskResource taskResource = adaptor.buildResource(response, TaskResource.class); taskResource = supplier.get().execute(this, taskResource, request.getTimeout()); return taskResource; } BaseClient(SDKConfiguration config, String hostname); protected  BaseClient(
            ResourceAdaptor adaptor,
            HttpRestClient client,
            Supplier<TaskMonitor> supplier,
            String hostname); void setSessionId(String sessionId); String getSessionId(); Object executeRequest(Request request, Type returnType); T executeRequest(Request request, Class<T> returnType); TaskResource executeMonitorableRequest(Request request);  }
@Test(expected = SDKInvalidArgumentException.class) public void shouldThrowExceptionWhenTryingToExecuteMonitorableRequestWithoutRequestObject() { this.baseClient.executeMonitorableRequest(null); }
@Test(expected = SDKNoResponseException.class) public void shouldThrowExceptionWhenServerReturnsNoResponseForExecuteMonitorableRequest() { given(httpClient.sendRequest(anyString(), any(Request.class))).willReturn(""); this.baseClient.executeMonitorableRequest(new Request(HttpMethod.GET, ANY_URI_STRING)); }
@Test public void shouldExecuteMonitorableRequest() { TaskMonitor monitor = mock(TaskMonitor.class); given(httpClient.sendRequest(anyString(), any(Request.class))).willReturn(ANY_TASK_RESOURCE); given(adaptor.buildResource(anyString(), eq(TaskResource.class))).willReturn(new TaskResource()); given(supplier.get()).willReturn(monitor); given(monitor.execute(any(BaseClient.class), any(TaskResource.class), anyInt())).willReturn(new TaskResource()); Request request = new Request(HttpMethod.GET, ANY_URI_STRING); this.baseClient.executeMonitorableRequest(request); then(httpClient).should().sendRequest(anyString(), eq(request)); }