MessageMarkingConfiguration extends AbstractConfiguration { public MessageMarkingStatus getMessageMarkingStatus() { LOG.debug("Call message marking status API."); MessageMarkingStatus status = null; JSONObject o = getterRequest(STATUS_GETTER_URL_POSTFIX); if (o != null) { Boolean messageMarking = (Boolean) o.get("messageMarking"); if (messageMarking) { status = MessageMarkingStatus.ON; } else { status = MessageMarkingStatus.OFF; } } return status; } MessageMarkingConfiguration(WilmaServiceConfig config);  MessageMarkingConfiguration(WilmaServiceConfig config, WilmaHttpClient client); MessageMarkingStatus getMessageMarkingStatus(); boolean setMessageMarkingStatus(MessageMarkingStatus control);  }
@Test public void shouldReturnNullIfClientReturnsOptionalAbsent() { when(client.sendGetterRequest(MARKING_STATUS_URL)).thenReturn(Optional.<String>absent()); MessageMarkingStatus result = messageMarkingConfiguration.getMessageMarkingStatus(); assertNull(result); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnJSONObjectWithProperValue() { when(client.sendGetterRequest(MARKING_STATUS_URL)).thenReturn(Optional.of(JSON_STRING)); MessageMarkingStatus result = messageMarkingConfiguration.getMessageMarkingStatus(); Assert.assertTrue(result == MessageMarkingStatus.ON); verify(client, never()).sendSetterRequest(anyString()); }