### Question:
MockableClient extends OkHttpClient { @Override public Call newCall(Request request) { if (shouldMockRequest(request)) { return mockedClient.newCall(request); } else { return realClient.newCall(request); } } MockableClient(Registry registry,
                   OkHttpClient realClient,
                   ReplaceEndpointClient mockedClient,
                   BooleanFunction mockWhenFunction); @Override Call newCall(Request request); static MockableClient.Builder baseUrl(String mockedBaseUrl);  }### Answer:
@Test public void notInRegistry_CallRealEndpoint() { givenWhenFunctionReturns(true); givenEndpointInRegistry(false); testee.newCall(REQUEST); verify(realClient).newCall(REQUEST); verify(mockClient, never()).newCall(any(Request.class)); }
@Test public void inRegistryAndShouldMock_CallMockedEndpoint() { givenWhenFunctionReturns(true); givenEndpointInRegistry(true); testee.newCall(REQUEST); verify(mockClient).newCall(REQUEST); verify(realClient, never()).newCall(any(Request.class)); }
@Test public void inRegistryButShouldNotMock_CallRealEndpoint() { givenWhenFunctionReturns(true); givenEndpointInRegistry(false); testee.newCall(REQUEST); verify(realClient).newCall(REQUEST); verify(mockClient, never()).newCall(any(Request.class)); }