ItBitExchangeAdapter extends AbstractExchangeAdapter implements ExchangeAdapter { @Override public void init(ExchangeConfig config) { LOG.info(() -> "About to initialise itBit ExchangeConfig: " + config); setAuthenticationConfig(config); setNetworkConfig(config); setOtherConfig(config); nonce = System.currentTimeMillis() / 1000; initSecureMessageLayer(); initGson(); }  @Override void init(ExchangeConfig config); @Override String createOrder(
      String marketId, OrderType orderType, BigDecimal quantity, BigDecimal price); @Override boolean cancelOrder(String orderId, String marketIdNotNeeded); @Override List<OpenOrder> getYourOpenOrders(String marketId); @Override MarketOrderBook getMarketOrders(String marketId); @Override BigDecimal getLatestMarketPrice(String marketId); @Override BalanceInfo getBalanceInfo(); @Override BigDecimal getPercentageOfBuyOrderTakenForExchangeFee(String marketId); @Override BigDecimal getPercentageOfSellOrderTakenForExchangeFee(String marketId); @Override String getImplName(); @Override Ticker getTicker(String marketId);  }
@Test public void testExchangeAdapterInitialisesSuccessfully() { PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); assertNotNull(exchangeAdapter); PowerMock.verify(); }
@Test(expected = IllegalArgumentException.class) public void testExchangeAdapterThrowsExceptionIfUserIdConfigIsMissing() { PowerMock.reset(authenticationConfig); expect(authenticationConfig.getItem("userId")).andReturn(null); expect(authenticationConfig.getItem("key")).andReturn("your_client_key"); expect(authenticationConfig.getItem("secret")).andReturn("your_client_secret"); PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); PowerMock.verify(); }
@Test(expected = IllegalArgumentException.class) public void testExchangeAdapterThrowsExceptionIfClientKeyConfigIsMissing() { PowerMock.reset(authenticationConfig); expect(authenticationConfig.getItem("userId")).andReturn("your-user-id"); expect(authenticationConfig.getItem("key")).andReturn(null); expect(authenticationConfig.getItem("secret")).andReturn("your_client_secret"); PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); PowerMock.verifyAll(); }
@Test(expected = IllegalArgumentException.class) public void testExchangeAdapterThrowsExceptionIfClientSecretConfigIsMissing() { PowerMock.reset(authenticationConfig); expect(authenticationConfig.getItem("userId")).andReturn("userId"); expect(authenticationConfig.getItem("key")).andReturn("your_client_key"); expect(authenticationConfig.getItem("secret")).andReturn(""); PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); PowerMock.verifyAll(); }
@Test(expected = IllegalArgumentException.class) public void testExchangeAdapterThrowsExceptionIfBuyFeeIsMissing() { PowerMock.reset(otherConfig); expect(otherConfig.getItem("buy-fee")).andReturn(""); expect(otherConfig.getItem("sell-fee")).andReturn("0.5"); PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); PowerMock.verifyAll(); }
@Test(expected = IllegalArgumentException.class) public void testExchangeAdapterThrowsExceptionIfSellFeeIsMissing() { PowerMock.reset(otherConfig); expect(otherConfig.getItem("buy-fee")).andReturn("0.5"); expect(otherConfig.getItem("sell-fee")).andReturn(null); PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); PowerMock.verifyAll(); }
@Test(expected = IllegalArgumentException.class) public void testExchangeAdapterThrowsExceptionIfTimeoutConfigIsMissing() { PowerMock.reset(networkConfig); expect(networkConfig.getConnectionTimeout()).andReturn(0); PowerMock.replayAll(); final ItBitExchangeAdapter exchangeAdapter = new ItBitExchangeAdapter(); exchangeAdapter.init(exchangeConfig); PowerMock.verifyAll(); }