### Question:
BaseClient { Response execute(OkHttpClient client, Request request, CookieStorage cookieStorage) { try { Response response = client.newCall(request).execute(); if(cookieStorage!= null && !response.headers(HttpHeaders.SET_COOKIE).isEmpty()) { cookieStorage.store(response.headers(HttpHeaders.SET_COOKIE)); } return response; } catch (IOException e) { e.printStackTrace(); return null; } }    }### Answer:
@Test public void testExecute_whenCookieStorageIsProvided_shouldStoreResponsesCookiesInAuthorization() { Mockito.when(mockResponse.headers(HttpHeaders.SET_COOKIE)).thenReturn(Arrays.asList("cookie-1", "cookie-2")); BaseClient.CookieStorage cookieStorage = new TestCookieStorage(); baseClient.execute(client, Mockito.mock(Request.class), cookieStorage); assertThat(cookieStorage.load()).contains("cookie-1", "cookie-2"); }
@Test public void testExecute_whenCookieStorageIsProvidedButNoCookiesAreSet_shouldStoreNothing() { BaseClient.CookieStorage storage = Mockito.mock(BaseClient.CookieStorage.class); baseClient.execute(client, Mockito.mock(Request.class), storage); Mockito.verifyZeroInteractions(storage); }