+ @Test
+ void shouldThrowHttpClientException_WhenCannotExecuteRequestToAPI() throws Exception{
+
+ //given
+ when(closeableHttpClient.execute(any(HttpGet.class))).thenThrow(IOException.class);
+
+ //when
+ HttpClientException exception =
+ assertThrows(HttpClientException.class,
+ () -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
+
+ //then
+ assertEquals(ExitCode.HTTP_CLIENT_EXCEPTION.getValue(), exception.applicationExitCode());
+ }
+
+ @Test
+ void shouldThrowHttpClientException_WhenCannotParseResponseToString() throws Exception{
+
+ //given
+ mockServerResponse(HTTP_OK, CORRECT_RESPONSE);
+ when(httpEntity.getContent()).thenThrow(IOException.class);
+
+ //when
+ HttpClientException exception =
+ assertThrows(HttpClientException.class,
+ () -> httpClient.retrieveCertServiceData(CA_NAME, CSR, ""));
+
+ //then
+ assertEquals(ExitCode.HTTP_CLIENT_EXCEPTION.getValue(), exception.applicationExitCode());
+ }
+