MessageLoggingConfiguration extends AbstractConfiguration { public MessageLoggingControlStatus getMessageLoggingStatus() { LOG.debug("Call message logging status API."); MessageLoggingControlStatus status = null; JSONObject o = getterRequest(STATUS_GETTER_URL_POSTFIX); if (o != null) { Boolean requestLogging = (Boolean) o.get("requestLogging"); Boolean responseLogging = (Boolean) o.get("responseLogging"); if (requestLogging && responseLogging) { status = MessageLoggingControlStatus.ON; } else { status = MessageLoggingControlStatus.OFF; } } return status; } MessageLoggingConfiguration(WilmaServiceConfig config);  MessageLoggingConfiguration(WilmaServiceConfig config, WilmaHttpClient client); MessageLoggingControlStatus getMessageLoggingStatus(); boolean setMessageLoggingStatus(MessageLoggingControlStatus control);  }
@Test public void shouldReturnNullIfClientReturnsOptionalAbsent() { when(client.sendGetterRequest(LOGGING_STATUS_URL)).thenReturn(Optional.<String>absent()); MessageLoggingControlStatus result = messageLoggingConfiguration.getMessageLoggingStatus(); assertNull(result); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnJSONObjectWithProperValue() { when(client.sendGetterRequest(LOGGING_STATUS_URL)).thenReturn(Optional.of(JSON_STRING)); MessageLoggingControlStatus result = messageLoggingConfiguration.getMessageLoggingStatus(); Assert.assertTrue(result == MessageLoggingControlStatus.ON); verify(client, never()).sendSetterRequest(anyString()); }