@Test public void shouldReturnNullIfClientReturnsOptionalAbsentForLoadInformation() { when(client.sendGetterRequest(ACTUAL_LOAD_INFO_URL)).thenReturn(Optional.<String>absent()); WilmaLoadInformation result = wilmaApplication.getActualLoadInformation(); assertNull("WilmaLoadInformation is expected to be null.", result); verify(client, never()).sendSetterRequest(anyString()); }
public WilmaLoadInformation getActualLoadInformation() { LOG.debug("Call actual load information API."); String url = buildUrl(ACTUAL_LOAD_INFO_URL_POSTFIX); WilmaLoadInformation loadInformation = null; LOG.debug("Send getter request to: " + url); Optional<String> response = wilmaClient.sendGetterRequest(url); if (response.isPresent()) { loadInformation = new WilmaLoadInformation(new JSONObject(response.get())); } return loadInformation; }
WilmaApplication { public WilmaLoadInformation getActualLoadInformation() { LOG.debug("Call actual load information API."); String url = buildUrl(ACTUAL_LOAD_INFO_URL_POSTFIX); WilmaLoadInformation loadInformation = null; LOG.debug("Send getter request to: " + url); Optional<String> response = wilmaClient.sendGetterRequest(url); if (response.isPresent()) { loadInformation = new WilmaLoadInformation(new JSONObject(response.get())); } return loadInformation; } }
WilmaApplication { public WilmaLoadInformation getActualLoadInformation() { LOG.debug("Call actual load information API."); String url = buildUrl(ACTUAL_LOAD_INFO_URL_POSTFIX); WilmaLoadInformation loadInformation = null; LOG.debug("Send getter request to: " + url); Optional<String> response = wilmaClient.sendGetterRequest(url); if (response.isPresent()) { loadInformation = new WilmaLoadInformation(new JSONObject(response.get())); } return loadInformation; } WilmaApplication(WilmaServiceConfig config);  WilmaApplication(WilmaServiceConfig config, WilmaHttpClient client); }
WilmaApplication { public WilmaLoadInformation getActualLoadInformation() { LOG.debug("Call actual load information API."); String url = buildUrl(ACTUAL_LOAD_INFO_URL_POSTFIX); WilmaLoadInformation loadInformation = null; LOG.debug("Send getter request to: " + url); Optional<String> response = wilmaClient.sendGetterRequest(url); if (response.isPresent()) { loadInformation = new WilmaLoadInformation(new JSONObject(response.get())); } return loadInformation; } WilmaApplication(WilmaServiceConfig config);  WilmaApplication(WilmaServiceConfig config, WilmaHttpClient client); String getVersionInformation(); WilmaLoadInformation getActualLoadInformation(); boolean shutdownApplication(); JSONObject callGetService(final String serviceQueryString); }
WilmaApplication { public WilmaLoadInformation getActualLoadInformation() { LOG.debug("Call actual load information API."); String url = buildUrl(ACTUAL_LOAD_INFO_URL_POSTFIX); WilmaLoadInformation loadInformation = null; LOG.debug("Send getter request to: " + url); Optional<String> response = wilmaClient.sendGetterRequest(url); if (response.isPresent()) { loadInformation = new WilmaLoadInformation(new JSONObject(response.get())); } return loadInformation; } WilmaApplication(WilmaServiceConfig config);  WilmaApplication(WilmaServiceConfig config, WilmaHttpClient client); String getVersionInformation(); WilmaLoadInformation getActualLoadInformation(); boolean shutdownApplication(); JSONObject callGetService(final String serviceQueryString);  }