FlowUpConfig { public boolean updateConfig() { ApiClientResult<Config> getConfigResult = apiClient.getConfig(); if (getConfigResult.isSuccess()) { Config config = getConfigResult.getValue(); Logger.d("New config value: " + config); storage.updateConfig(config); } return getConfigResult.isSuccess(); } FlowUpConfig(ConfigStorage storage, ConfigApiClient apiClient); Config getConfig(); boolean updateConfig(); void disableClient();  }
@Test public void returnsFalseIfTheApiClientReturnsAnErrorDuringTheUpdate() throws Exception { givenThereIsNoConnection(); boolean result = flowUpConfig.updateConfig(); assertFalse(result); }
@Test public void returnsTrueIfTheApiClientObtainsTheConfigProperlyDuringTheUpdate() throws Exception { givenTheApiReturnsANewConfig(); boolean result = flowUpConfig.updateConfig(); assertTrue(result); }
@Test public void updatesTheConfigPersistedDuringTheUpdateProcess() throws Exception { Config newConfig = givenTheApiReturnsANewConfig(); flowUpConfig.updateConfig(); verify(storage).updateConfig(newConfig); }