WilmaApplication { public String getVersionInformation() { LOG.debug("Call version information API."); String url = buildUrl(VERSION_INFO_URL_POSTFIX); String version = null; LOG.debug("Send getter request to: " + url); Optional<String> response = wilmaClient.sendGetterRequest(url); if (response.isPresent()) { JSONObject o = new JSONObject(response.get()); version = o.getString("wilmaVersion"); } return version; } WilmaApplication(WilmaServiceConfig config);  WilmaApplication(WilmaServiceConfig config, WilmaHttpClient client); String getVersionInformation(); WilmaLoadInformation getActualLoadInformation(); boolean shutdownApplication(); JSONObject callGetService(final String serviceQueryString);  }
@Test public void shouldReturnNullIfClientReturnsOptionalAbsentForVersionInformation() { when(client.sendGetterRequest(VERSION_INFO_URL)).thenReturn(Optional.<String>absent()); String result = wilmaApplication.getVersionInformation(); assertNull("WilmaVersionInformation is expected to be null.", result); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnWithProperValueForVersionInformation() { when(client.sendGetterRequest(VERSION_INFO_URL)).thenReturn(Optional.of(VERSION_INFO_JSON_STRING)); String result = wilmaApplication.getVersionInformation(); verify(client, never()).sendSetterRequest(anyString()); Assert.assertTrue("Wilma Version Information content is wrong.", VERSION_INFO_JSON_STRING.contains(result)); }