@Test public void testBuildingConfigWithoutOptionalNetworkConfig() { final com.gazbert.bxbot.exchange.api.ExchangeConfig exchangeApiConfig = ExchangeApiConfigBuilder.buildConfig(buildExchangeConfigWithoutOptionalNetworkConfig()); assertThat(exchangeApiConfig.getExchangeName()).isEqualTo(EXCHANGE_NAME); assertThat(exchangeApiConfig.getExchangeAdapter()).isEqualTo(EXCHANGE_ADAPTER); assertThat(exchangeApiConfig.getAuthenticationConfig().getItem(API_KEY_CONFIG_ITEM_KEY)) .isEqualTo(API_KEY_CONFIG_ITEM_VALUE); assertThat(exchangeApiConfig.getAuthenticationConfig().getItem(SECRET_CONFIG_ITEM_KEY)) .isEqualTo(SECRET_FEE_CONFIG_ITEM_VALUE); assertThat(exchangeApiConfig.getNetworkConfig().getConnectionTimeout()) .isEqualTo(CONNECTION_TIMEOUT); assertThat(exchangeApiConfig.getNetworkConfig().getNonFatalErrorCodes()).isEmpty(); assertThat(exchangeApiConfig.getNetworkConfig().getNonFatalErrorMessages()).isEmpty(); assertThat(exchangeApiConfig.getOtherConfig().getItem(BUY_FEE_CONFIG_ITEM_KEY)) .isEqualTo(BUY_FEE_CONFIG_ITEM_VALUE); assertThat(exchangeApiConfig.getOtherConfig().getItem(SELL_FEE_CONFIG_ITEM_KEY)) .isEqualTo(SELL_FEE_CONFIG_ITEM_VALUE); }
public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { final ExchangeConfigImpl exchangeApiConfig = new ExchangeConfigImpl(); exchangeApiConfig.setExchangeName(exchangeConfig.getName()); exchangeApiConfig.setExchangeAdapter(exchangeConfig.getAdapter()); final NetworkConfig networkConfig = exchangeConfig.getNetworkConfig(); if (networkConfig != null) { final NetworkConfigImpl exchangeApiNetworkConfig = new NetworkConfigImpl(); exchangeApiNetworkConfig.setConnectionTimeout(networkConfig.getConnectionTimeout()); final List<Integer> nonFatalErrorCodes = networkConfig.getNonFatalErrorCodes(); if (nonFatalErrorCodes != null && !nonFatalErrorCodes.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } final List<String> nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages(); if (nonFatalErrorMessages != null && !nonFatalErrorMessages.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig); LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig); } else { LOG.info( () -> "No (optional) NetworkConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> authenticationConfig = exchangeConfig.getAuthenticationConfig(); if (authenticationConfig != null) { final AuthenticationConfigImpl exchangeApiAuthenticationConfig = new AuthenticationConfigImpl(); exchangeApiAuthenticationConfig.setItems(authenticationConfig); exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig); LOG.info(() -> "AuthenticationConfiguration has been set successfully."); } else { LOG.info( () -> "No (optional) AuthenticationConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> otherConfig = exchangeConfig.getOtherConfig(); if (otherConfig != null) { final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl(); exchangeApiOtherConfig.setItems(otherConfig); exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig); LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig); } else { LOG.info( () -> "No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } return exchangeApiConfig; }
ExchangeApiConfigBuilder { public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { final ExchangeConfigImpl exchangeApiConfig = new ExchangeConfigImpl(); exchangeApiConfig.setExchangeName(exchangeConfig.getName()); exchangeApiConfig.setExchangeAdapter(exchangeConfig.getAdapter()); final NetworkConfig networkConfig = exchangeConfig.getNetworkConfig(); if (networkConfig != null) { final NetworkConfigImpl exchangeApiNetworkConfig = new NetworkConfigImpl(); exchangeApiNetworkConfig.setConnectionTimeout(networkConfig.getConnectionTimeout()); final List<Integer> nonFatalErrorCodes = networkConfig.getNonFatalErrorCodes(); if (nonFatalErrorCodes != null && !nonFatalErrorCodes.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } final List<String> nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages(); if (nonFatalErrorMessages != null && !nonFatalErrorMessages.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig); LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig); } else { LOG.info( () -> "No (optional) NetworkConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> authenticationConfig = exchangeConfig.getAuthenticationConfig(); if (authenticationConfig != null) { final AuthenticationConfigImpl exchangeApiAuthenticationConfig = new AuthenticationConfigImpl(); exchangeApiAuthenticationConfig.setItems(authenticationConfig); exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig); LOG.info(() -> "AuthenticationConfiguration has been set successfully."); } else { LOG.info( () -> "No (optional) AuthenticationConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> otherConfig = exchangeConfig.getOtherConfig(); if (otherConfig != null) { final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl(); exchangeApiOtherConfig.setItems(otherConfig); exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig); LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig); } else { LOG.info( () -> "No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } return exchangeApiConfig; } }
ExchangeApiConfigBuilder { public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { final ExchangeConfigImpl exchangeApiConfig = new ExchangeConfigImpl(); exchangeApiConfig.setExchangeName(exchangeConfig.getName()); exchangeApiConfig.setExchangeAdapter(exchangeConfig.getAdapter()); final NetworkConfig networkConfig = exchangeConfig.getNetworkConfig(); if (networkConfig != null) { final NetworkConfigImpl exchangeApiNetworkConfig = new NetworkConfigImpl(); exchangeApiNetworkConfig.setConnectionTimeout(networkConfig.getConnectionTimeout()); final List<Integer> nonFatalErrorCodes = networkConfig.getNonFatalErrorCodes(); if (nonFatalErrorCodes != null && !nonFatalErrorCodes.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } final List<String> nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages(); if (nonFatalErrorMessages != null && !nonFatalErrorMessages.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig); LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig); } else { LOG.info( () -> "No (optional) NetworkConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> authenticationConfig = exchangeConfig.getAuthenticationConfig(); if (authenticationConfig != null) { final AuthenticationConfigImpl exchangeApiAuthenticationConfig = new AuthenticationConfigImpl(); exchangeApiAuthenticationConfig.setItems(authenticationConfig); exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig); LOG.info(() -> "AuthenticationConfiguration has been set successfully."); } else { LOG.info( () -> "No (optional) AuthenticationConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> otherConfig = exchangeConfig.getOtherConfig(); if (otherConfig != null) { final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl(); exchangeApiOtherConfig.setItems(otherConfig); exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig); LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig); } else { LOG.info( () -> "No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } return exchangeApiConfig; } private  ExchangeApiConfigBuilder(); }
ExchangeApiConfigBuilder { public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { final ExchangeConfigImpl exchangeApiConfig = new ExchangeConfigImpl(); exchangeApiConfig.setExchangeName(exchangeConfig.getName()); exchangeApiConfig.setExchangeAdapter(exchangeConfig.getAdapter()); final NetworkConfig networkConfig = exchangeConfig.getNetworkConfig(); if (networkConfig != null) { final NetworkConfigImpl exchangeApiNetworkConfig = new NetworkConfigImpl(); exchangeApiNetworkConfig.setConnectionTimeout(networkConfig.getConnectionTimeout()); final List<Integer> nonFatalErrorCodes = networkConfig.getNonFatalErrorCodes(); if (nonFatalErrorCodes != null && !nonFatalErrorCodes.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } final List<String> nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages(); if (nonFatalErrorMessages != null && !nonFatalErrorMessages.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig); LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig); } else { LOG.info( () -> "No (optional) NetworkConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> authenticationConfig = exchangeConfig.getAuthenticationConfig(); if (authenticationConfig != null) { final AuthenticationConfigImpl exchangeApiAuthenticationConfig = new AuthenticationConfigImpl(); exchangeApiAuthenticationConfig.setItems(authenticationConfig); exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig); LOG.info(() -> "AuthenticationConfiguration has been set successfully."); } else { LOG.info( () -> "No (optional) AuthenticationConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> otherConfig = exchangeConfig.getOtherConfig(); if (otherConfig != null) { final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl(); exchangeApiOtherConfig.setItems(otherConfig); exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig); LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig); } else { LOG.info( () -> "No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } return exchangeApiConfig; } private  ExchangeApiConfigBuilder(); static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig); }
ExchangeApiConfigBuilder { public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { final ExchangeConfigImpl exchangeApiConfig = new ExchangeConfigImpl(); exchangeApiConfig.setExchangeName(exchangeConfig.getName()); exchangeApiConfig.setExchangeAdapter(exchangeConfig.getAdapter()); final NetworkConfig networkConfig = exchangeConfig.getNetworkConfig(); if (networkConfig != null) { final NetworkConfigImpl exchangeApiNetworkConfig = new NetworkConfigImpl(); exchangeApiNetworkConfig.setConnectionTimeout(networkConfig.getConnectionTimeout()); final List<Integer> nonFatalErrorCodes = networkConfig.getNonFatalErrorCodes(); if (nonFatalErrorCodes != null && !nonFatalErrorCodes.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } final List<String> nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages(); if (nonFatalErrorMessages != null && !nonFatalErrorMessages.isEmpty()) { exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages); } else { LOG.info( () -> "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for " + "Exchange Adapter: " + exchangeConfig.getAdapter()); } exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig); LOG.info(() -> "NetworkConfiguration has been set: " + exchangeApiNetworkConfig); } else { LOG.info( () -> "No (optional) NetworkConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> authenticationConfig = exchangeConfig.getAuthenticationConfig(); if (authenticationConfig != null) { final AuthenticationConfigImpl exchangeApiAuthenticationConfig = new AuthenticationConfigImpl(); exchangeApiAuthenticationConfig.setItems(authenticationConfig); exchangeApiConfig.setAuthenticationConfig(exchangeApiAuthenticationConfig); LOG.info(() -> "AuthenticationConfiguration has been set successfully."); } else { LOG.info( () -> "No (optional) AuthenticationConfiguration has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } final Map<String, String> otherConfig = exchangeConfig.getOtherConfig(); if (otherConfig != null) { final OtherConfigImpl exchangeApiOtherConfig = new OtherConfigImpl(); exchangeApiOtherConfig.setItems(otherConfig); exchangeApiConfig.setOtherConfig(exchangeApiOtherConfig); LOG.info(() -> "Other Exchange Adapter config has been set: " + exchangeApiOtherConfig); } else { LOG.info( () -> "No Other config has been set for Exchange Adapter: " + exchangeConfig.getAdapter()); } return exchangeApiConfig; } private  ExchangeApiConfigBuilder(); static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig);  }