OperationConfiguration extends AbstractConfiguration { public OperationMode getOperationMode() { LOG.debug("Call operation status API."); OperationMode status = null; JSONObject o = getterRequest(STATUS_GETTER_URL_POSTFIX); if (o != null) { Boolean proxyMode = (Boolean) o.get("proxyMode"); Boolean stubMode = (Boolean) o.get("stubMode"); Boolean wilmaMode = (Boolean) o.get("wilmaMode"); if (proxyMode) { status = OperationMode.PROXY; } if (stubMode) { status = OperationMode.STUB; } if (wilmaMode) { status = OperationMode.WILMA; } } return status; } OperationConfiguration(WilmaServiceConfig config);  OperationConfiguration(WilmaServiceConfig config, WilmaHttpClient client); OperationMode getOperationMode(); boolean setOperationMode(OperationMode mode);  }
@Test public void shouldReturnNullIfClientReturnsOptionalAbsent() { when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.<String>absent()); OperationMode result = operationConfiguration.getOperationMode(); assertNull(result); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnWithProperValueWilma() { when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING_WILMA_MODE)); OperationMode result = operationConfiguration.getOperationMode(); assertTrue(result == OperationMode.WILMA, "The operation mode should be WILMA."); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnWithProperValueStub() { when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING_STUB_MODE)); OperationMode result = operationConfiguration.getOperationMode(); assertTrue(result == OperationMode.STUB, "The operation mode should be STUB."); verify(client, never()).sendSetterRequest(anyString()); }
@Test public void shouldReturnWithProperValueProxy() { when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING_PROXY_MODE)); OperationMode result = operationConfiguration.getOperationMode(); assertTrue(result == OperationMode.PROXY, "The operation mode should be PROXY."); verify(client, never()).sendSetterRequest(anyString()); }