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);  }
@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()); }
@Test public void shouldReturnWithProperValueForLoadInformation() { when(client.sendGetterRequest(ACTUAL_LOAD_INFO_URL)).thenReturn(Optional.of(LOAD_INFO_JSON_STRING)); WilmaLoadInformation result = wilmaApplication.getActualLoadInformation(); verify(client, never()).sendSetterRequest(anyString()); Assert.assertTrue("Wilma Load Information content is wrong.", result.getDeletedFilesCount() == 0); Assert.assertTrue("Wilma Load Information content is wrong.", result.getCountOfMessages() == 1); Assert.assertTrue("Wilma Load Information content is wrong.", result.getResponseQueueSize() == 2); Assert.assertTrue("Wilma Load Information content is wrong.", result.getLoggerQueueSize() == 3); }