StubConfiguration extends AbstractConfiguration { public JSONObject getStubConfigInformation() { LOG.debug("Call stub configuration API."); return getterRequest(STATUS_GETTER_URL_POSTFIX); } StubConfiguration(WilmaServiceConfig config);  StubConfiguration(WilmaServiceConfig config, WilmaHttpClient client); JSONObject getStubConfigInformation(); boolean setStubConfigStatus(String groupName, StubConfigStatus status); boolean setStubConfigOrder(String groupName, StubConfigOrder order); boolean dropStubConfig(String groupName); boolean dropAllStubConfig(); boolean persistActualStubConfig();  }
@Test public void shouldReturnNullJSONObjectIfClientReturnsOptionalAbsent() { when(client.sendGetterRequest(STUB_STATUS_URL)).thenReturn(Optional.<String>absent()); JSONObject result = stubConfiguration.getStubConfigInformation(); assertNull(result); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnJSONObjectWithProperValue() { when(client.sendGetterRequest(STUB_STATUS_URL)).thenReturn(Optional.of(JSON_STRING)); JSONObject result = stubConfiguration.getStubConfigInformation(); assertTrue(new JSONObject(JSON_STRING).similar(result), "The two JSON objects should be similar."); verify(client, never()).sendSetterRequest(anyString()); }