@Test public void whenSaveCalledThenExpectRepositoryToSaveItAndReturnSavedEngineConfig() { ConfigurationManager.saveConfig(eq(EngineType.class), anyObject(EngineType.class), eq(ENGINE_CONFIG_YAML_FILENAME)); expect(ConfigurationManager.loadConfig( eq(EngineType.class), eq(ENGINE_CONFIG_YAML_FILENAME))) .andReturn(someInternalEngineConfig()); PowerMock.replayAll(); final EngineConfigRepository engineConfigRepository = new EngineConfigYamlRepository(); final EngineConfig savedConfig = engineConfigRepository.save(someExternalEngineConfig()); assertThat(savedConfig.getBotId()).isEqualTo(BOT_ID); assertThat(savedConfig.getBotName()).isEqualTo(BOT_NAME); assertThat(savedConfig.getEmergencyStopCurrency()).isEqualTo(ENGINE_EMERGENCY_STOP_CURRENCY); assertThat(savedConfig.getEmergencyStopBalance()).isEqualTo(ENGINE_EMERGENCY_STOP_BALANCE); assertThat(savedConfig.getTradeCycleInterval()).isEqualTo(ENGINE_TRADE_CYCLE_INTERVAL); PowerMock.verifyAll(); }
@Override public EngineConfig save(EngineConfig config) { LOG.info(() -> "About to save EngineConfig: " + config); final EngineType engineType = new EngineType(); engineType.setEngine(config); ConfigurationManager.saveConfig(EngineType.class, engineType, ENGINE_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EngineType.class, ENGINE_CONFIG_YAML_FILENAME) .getEngine(); }
EngineConfigYamlRepository implements EngineConfigRepository { @Override public EngineConfig save(EngineConfig config) { LOG.info(() -> "About to save EngineConfig: " + config); final EngineType engineType = new EngineType(); engineType.setEngine(config); ConfigurationManager.saveConfig(EngineType.class, engineType, ENGINE_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EngineType.class, ENGINE_CONFIG_YAML_FILENAME) .getEngine(); } }
EngineConfigYamlRepository implements EngineConfigRepository { @Override public EngineConfig save(EngineConfig config) { LOG.info(() -> "About to save EngineConfig: " + config); final EngineType engineType = new EngineType(); engineType.setEngine(config); ConfigurationManager.saveConfig(EngineType.class, engineType, ENGINE_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EngineType.class, ENGINE_CONFIG_YAML_FILENAME) .getEngine(); }  }
EngineConfigYamlRepository implements EngineConfigRepository { @Override public EngineConfig save(EngineConfig config) { LOG.info(() -> "About to save EngineConfig: " + config); final EngineType engineType = new EngineType(); engineType.setEngine(config); ConfigurationManager.saveConfig(EngineType.class, engineType, ENGINE_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EngineType.class, ENGINE_CONFIG_YAML_FILENAME) .getEngine(); }  @Override EngineConfig get(); @Override EngineConfig save(EngineConfig config); }
EngineConfigYamlRepository implements EngineConfigRepository { @Override public EngineConfig save(EngineConfig config) { LOG.info(() -> "About to save EngineConfig: " + config); final EngineType engineType = new EngineType(); engineType.setEngine(config); ConfigurationManager.saveConfig(EngineType.class, engineType, ENGINE_CONFIG_YAML_FILENAME); return ConfigurationManager.loadConfig(EngineType.class, ENGINE_CONFIG_YAML_FILENAME) .getEngine(); }  @Override EngineConfig get(); @Override EngineConfig save(EngineConfig config);  }