### Question:
ServerGatewayImpl implements ServerGateway { @Override public <T> void sendStats(T payload, String url) throws GatewayException { try { HttpEntity httpEntity = EntityBuilder.create() .setContentType(ContentType.APPLICATION_JSON) .setText(new Gson().toJson(payload)) .build(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(httpEntity); HttpClient httpClient = createHttpClient(); httpClient.execute(httpPost); log.debug("Sending to {} data: {}", url, payload); } catch (Exception e) { throw new GatewayException("Exception sending to server", e); } }  @Override void sendStats(T payload, String url); HttpClient createHttpClient();  }### Answer:
@Test(expected = GatewayException.class) public void testInvalidURL() throws Exception { ServerGateway serverGateway = mock(ServerGatewayImpl.class, Answers.CALLS_REAL_METHODS); Map<String, String> map = new HashMap<>(); map.put("key1", "val1"); map.put("key2", "val2"); serverGateway.sendStats(map, null); }