Search in sources :

Example 1 with BleutradeCurrenciesReturn

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]);
    }
}
Also used : BleutradeCurrency(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrency) BleutradeCurrenciesReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn) Test(org.junit.Test)

Example 2 with BleutradeCurrenciesReturn

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);
}
Also used : BleutradeCurrenciesReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn) Test(org.junit.Test)

Example 3 with BleutradeCurrenciesReturn

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");
}
Also used : BleutradeCurrenciesReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn) Test(org.junit.Test)

Example 4 with BleutradeCurrenciesReturn

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]");
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BleutradeMarketsReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeMarketsReturn) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) IRestProxyFactory(si.mazi.rescu.IRestProxyFactory) BigDecimal(java.math.BigDecimal) Currency(org.knowm.xchange.currency.Currency) ClientConfig(si.mazi.rescu.ClientConfig) BleutradeCurrenciesReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 5 with BleutradeCurrenciesReturn

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]);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BleutradeMarketsReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeMarketsReturn) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) BleutradeCurrenciesReturn(org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 BleutradeCurrenciesReturn (org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrenciesReturn)6 BleutradeMarketsReturn (org.knowm.xchange.bleutrade.dto.marketdata.BleutradeMarketsReturn)2 Currency (org.knowm.xchange.currency.Currency)2 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)2 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)2 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)2 BigDecimal (java.math.BigDecimal)1 BleutradeCurrency (org.knowm.xchange.bleutrade.dto.marketdata.BleutradeCurrency)1 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)1 ClientConfig (si.mazi.rescu.ClientConfig)1 IRestProxyFactory (si.mazi.rescu.IRestProxyFactory)1