LocalhostBlockingConfiguration extends AbstractConfiguration { public LocalhostControlStatus getLocalhostBlockingStatus() { LOG.debug("Call localhost blocking status API."); LocalhostControlStatus status = null; JSONObject o = getterRequest(STATUS_GETTER_URL_POSTFIX); if (o != null) { Boolean localhostMode = (Boolean) o.get("localhostMode"); if (localhostMode) { status = LocalhostControlStatus.ON; } else { status = LocalhostControlStatus.OFF; } } return status; } LocalhostBlockingConfiguration(WilmaServiceConfig config);  LocalhostBlockingConfiguration(WilmaServiceConfig config, WilmaHttpClient client); LocalhostControlStatus getLocalhostBlockingStatus(); boolean setLocalhostBlockingStatus(LocalhostControlStatus control);  }
@Test public void shouldReturnNullIfClientReturnsOptionalAbsent() { when(client.sendGetterRequest(LOCALHOST_BLOCKING_STATUS_URL)).thenReturn(Optional.<String>absent()); LocalhostControlStatus result = localhostBlockingConfiguration.getLocalhostBlockingStatus(); assertNull(result); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnWithProperValue() { when(client.sendGetterRequest(LOCALHOST_BLOCKING_STATUS_URL)).thenReturn(Optional.of(JSON_STRING)); LocalhostControlStatus result = localhostBlockingConfiguration.getLocalhostBlockingStatus(); assertTrue(result == LocalhostControlStatus.ON); verify(client, never()).sendSetterRequest(anyString()); }