use of org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn in project XChange by knowm.
the class BleutradeMarketDataServiceIntegration method shouldGetCurrencies.
@Test
public void shouldGetCurrencies() throws IOException {
// given
final List<BleutradeCurrency> expectedBleutradeCurrencies = expectedBleutradeCurrencies();
final String[] expectedBleutradeCurrenciesStr = expectedBleutradeCurrenciesStr();
BleutradeCurrenciesReturn currenciesReturn = new BleutradeCurrenciesReturn();
currenciesReturn.setSuccess(true);
currenciesReturn.setMessage("test message");
currenciesReturn.setResult(expectedBleutradeCurrencies);
when(bleutrade.getBleutradeCurrencies()).thenReturn(currenciesReturn);
// when
List<BleutradeCurrency> currencies = marketDataService.getBleutradeCurrencies();
// then
assertThat(currencies).hasSize(2);
for (int i = 0; i < currencies.size(); i++) {
BleutradeAssert.assertEquals(currencies.get(i), expectedBleutradeCurrencies.get(i));
assertThat(currencies.get(i).toString()).isEqualTo(expectedBleutradeCurrenciesStr[i]);
}
}
use of org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn in project XChange by knowm.
the class BleutradeExtendedDtoTest method shouldParseExtendedCurrenciesReturn.
@Test
public void shouldParseExtendedCurrenciesReturn() throws IOException {
// when
final BleutradeCurrenciesReturn response = parse("org/knowm/xchange/bleutrade/dto/" + "ExtendedCurrenciesReturn", BleutradeCurrenciesReturn.class);
// then
assertThat(response.toString()).isEqualTo(CURRENCIES_RETURN_STR);
}
use of org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn in project XChange by knowm.
the class BleutradeMarketDataServiceIntegration method shouldFailOnUnsuccesfulGetCurrencies.
@Test(expected = ExchangeException.class)
public void shouldFailOnUnsuccesfulGetCurrencies() throws IOException {
// given
BleutradeCurrenciesReturn currenciesReturn = new BleutradeCurrenciesReturn();
currenciesReturn.setSuccess(false);
currenciesReturn.setMessage("test message");
currenciesReturn.setResult(expectedBleutradeCurrencies());
when(bleutrade.getBleutradeCurrencies()).thenReturn(currenciesReturn);
// when
marketDataService.getBleutradeCurrencies();
// then
fail("BleutradeMarketDataService should throw ExchangeException when currencies request was unsuccessful");
}
use of org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn in project XChange by knowm.
the class BleutradeExchangeIntegration method shouldMakeRemoteInit.
@Test
public void shouldMakeRemoteInit() throws IOException {
// given
BleutradeCurrenciesReturn bleutradeCurrenciesReturn = new BleutradeCurrenciesReturn(asList(createBleutradeCurrency("BTC", "Bitcoin", 2, new BigDecimal("0.00080000"), true, "BITCOIN"), createBleutradeCurrency("LTC", "Litecoin", 4, new BigDecimal("0.02000000"), true, "BITCOIN")));
BleutradeMarketsReturn bleutradeMarketsReturn = new BleutradeMarketsReturn(asList(createBleutradeMarket("DOGE", "BTC", "Dogecoin", "Bitcoin", new BigDecimal("0.10000000"), "DOGE_BTC", true), createBleutradeMarket("BLEU", "BTC", "Bleutrade Share", "Bitcoin", new BigDecimal("0.00000001"), "BLEU_BTC", true)));
BleutradeAuthenticated bleutrade = mock(BleutradeAuthenticated.class);
when(bleutrade.getBleutradeCurrencies()).thenReturn(bleutradeCurrenciesReturn);
when(bleutrade.getBleutradeMarkets()).thenReturn(bleutradeMarketsReturn);
IRestProxyFactory restProxyFactory = mock(IRestProxyFactory.class);
when(restProxyFactory.createProxy(eq(BleutradeAuthenticated.class), any(String.class), any(ClientConfig.class))).thenReturn(bleutrade);
BleutradeExchange mockExchange = new BleutradeExchange(restProxyFactory);
mockExchange.applySpecification(mockExchange.getDefaultExchangeSpecification());
mockExchange.initServices();
// when
mockExchange.remoteInit();
// then
Map<Currency, CurrencyMetaData> currencyMetaDataMap = mockExchange.getExchangeMetaData().getCurrencies();
assertThat(currencyMetaDataMap).hasSize(2);
assertThat(currencyMetaDataMap.get(Currency.BTC).getScale()).isEqualTo(8);
assertThat(currencyMetaDataMap.get(Currency.LTC).getScale()).isEqualTo(8);
Map<CurrencyPair, CurrencyPairMetaData> marketMetaDataMap = mockExchange.getExchangeMetaData().getCurrencyPairs();
assertThat(marketMetaDataMap).hasSize(2);
assertThat(marketMetaDataMap.get(CurrencyPair.DOGE_BTC).toString()).isEqualTo("CurrencyPairMetaData [tradingFee=0.0025, minimumAmount=0.10000000, maximumAmount=null, baseScale=null, priceScale=8, volumeScale=null, amountStepSize=null, tradingFeeCurrency=null]");
assertThat(marketMetaDataMap.get(BLEU_BTC_CP).toString()).isEqualTo("CurrencyPairMetaData [tradingFee=0.0025, minimumAmount=1E-8, maximumAmount=null, baseScale=null, priceScale=8, volumeScale=null, amountStepSize=null, tradingFeeCurrency=null]");
}
use of org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn in project XChange by knowm.
the class BleutradeAdaptersTest method shouldAdaptExchangeMetaData.
@Test
public void shouldAdaptExchangeMetaData() throws IOException {
// given
final BleutradeCurrenciesReturn currenciesResponse = parse(BleutradeCurrenciesReturn.class);
final BleutradeMarketsReturn marketsResponse = parse(BleutradeMarketsReturn.class);
final CurrencyPairMetaData[] expectedMetaDataList = expectedMetaDataList();
final String[] expectedMetaDataStr = expectedMetaDataStr();
// when
ExchangeMetaData exchangeMetaData = BleutradeAdapters.adaptToExchangeMetaData(currenciesResponse.getResult(), marketsResponse.getResult());
// then
Map<Currency, CurrencyMetaData> currencyMetaDataMap = exchangeMetaData.getCurrencies();
assertThat(currencyMetaDataMap).hasSize(2);
assertThat(currencyMetaDataMap.get(Currency.BTC).getScale()).isEqualTo(8);
assertThat(currencyMetaDataMap.get(Currency.LTC).getScale()).isEqualTo(8);
Map<CurrencyPair, CurrencyPairMetaData> marketMetaDataMap = exchangeMetaData.getCurrencyPairs();
assertThat(marketMetaDataMap).hasSize(2);
// there is no reliable information about valid tradingFee calculation formula
BleutradeAssert.assertEquals(marketMetaDataMap.get(CurrencyPair.DOGE_BTC), expectedMetaDataList[0]);
assertThat(marketMetaDataMap.get(CurrencyPair.DOGE_BTC).toString()).isEqualTo(expectedMetaDataStr[0]);
BleutradeAssert.assertEquals(marketMetaDataMap.get(BLEU_BTC_CP), expectedMetaDataList[1]);
assertThat(marketMetaDataMap.get(BLEU_BTC_CP).toString()).isEqualTo(expectedMetaDataStr[1]);
}
Aggregations