Skip to content

Commit

Permalink
Merge pull request #4875 from bigscoop/code-cleanup
Browse files Browse the repository at this point in the history
[general] Remove method implementation that just throw exception
  • Loading branch information
timmolter authored May 22, 2024
2 parents ae208df + 2cab9c9 commit 0b77a88
Show file tree
Hide file tree
Showing 30 changed files with 43 additions and 414 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.knowm.xchange.bibox.service;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.knowm.xchange.Exchange;
Expand All @@ -11,12 +10,10 @@
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.dto.account.FundingRecord.Type;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.params.HistoryParamsFundingType;
import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency;
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
import org.knowm.xchange.service.trade.params.WithdrawFundsParams;

/**
* @author odrotleff
Expand All @@ -33,19 +30,6 @@ public AccountInfo getAccountInfo() throws IOException {
return BiboxAdapters.adaptAccountInfo(getBiboxAccountInfo());
}

@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
throws IOException {
throw new NotYetImplementedForExchangeException(
"This operation is not yet implemented for this exchange");
}

@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
throw new NotYetImplementedForExchangeException(
"This operation is not yet implemented for this exchange");
}

@Override
public String requestDepositAddress(Currency currency, String... args) throws IOException {
return requestBiboxDepositAddress(currency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.MarketOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.dto.trade.StopOrder;
import org.knowm.xchange.dto.trade.UserTrades;
import org.knowm.xchange.exceptions.ExchangeException;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.CancelOrderByIdParams;
import org.knowm.xchange.service.trade.params.CancelOrderParams;
Expand Down Expand Up @@ -71,21 +69,4 @@ public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException
return BiboxAdapters.adaptUserTrades(getBiboxOrderHistory());
}

@Override
public TradeHistoryParams createTradeHistoryParams() {
throw new NotYetImplementedForExchangeException(
"This operation is not yet implemented for this exchange");
}

@Override
public OpenOrdersParams createOpenOrdersParams() {
throw new NotYetImplementedForExchangeException(
"This operation is not yet implemented for this exchange");
}

@Override
public String placeStopOrder(StopOrder arg0) throws IOException {
throw new NotYetImplementedForExchangeException(
"This operation is not yet implemented for this exchange");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import org.knowm.xchange.bitz.service.BitZMarketDataService;
import org.knowm.xchange.bitz.service.BitZTradeService;
import org.knowm.xchange.exceptions.NotAvailableFromExchangeException;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.TradeService;

public class BitZExchange extends BaseExchange implements Exchange {

Expand All @@ -31,12 +29,6 @@ public ExchangeSpecification getDefaultExchangeSpecification() {
return exchangeSpecification;
}

@Override
public TradeService getTradeService() {
throw new NotYetImplementedForExchangeException(
"Parital implementation due to partial implementation by the exchange");
}

@Override
public AccountService getAccountService() {
throw new NotAvailableFromExchangeException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.bitz.BitZ;
import org.knowm.xchange.bitz.BitZAuthenticated;
import org.knowm.xchange.bitz.dto.account.result.BitZUserAssetsResult;
import org.knowm.xchange.bitz.dto.marketdata.BitZPublicOrder;
import org.knowm.xchange.bitz.dto.trade.result.BitZEntrustSheetInfoResult;
import org.knowm.xchange.bitz.dto.trade.result.BitZTradeAddResult;
import org.knowm.xchange.bitz.dto.trade.result.BitZTradeCancelListResult;
import org.knowm.xchange.bitz.dto.trade.result.BitZTradeCancelResult;
import org.knowm.xchange.bitz.dto.trade.result.BitZUserHistoryResult;
import org.knowm.xchange.client.ExchangeRestProxyBuilder;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import si.mazi.rescu.SynchronizedValueFactory;

public class BitZTradeServiceRaw extends BitZBaseService {
Expand Down Expand Up @@ -51,18 +47,6 @@ public BitZTradeServiceRaw(Exchange exchange) {
this.nonce = nonceFactory.toString().substring(nonceFactory.toString().length() - 6);
}

// TODO: Implement Method
public boolean cancelBitZTrade(int orderId) throws IOException {
throw new NotYetImplementedForExchangeException();
}

// TODO: Implement Method
public BitZTradeAddResult placeBitZTrade(
CurrencyPair currencyPair, BitZPublicOrder limitOrder, Date time, boolean sell)
throws IOException {
throw new NotYetImplementedForExchangeException();
}

private String getTimeStamp() {
return String.valueOf(System.currentTimeMillis() / 1000);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.knowm.xchange.blockchain.service;

import static org.knowm.xchange.blockchain.BlockchainConstants.*;
import static org.knowm.xchange.blockchain.BlockchainConstants.FUNDING_RECORD_TYPE_UNSUPPORTED;
import static org.knowm.xchange.blockchain.BlockchainConstants.WITHDRAWAL_EXCEPTION;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -21,11 +21,18 @@
import org.knowm.xchange.client.ResilienceRegistries;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.account.*;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.AddressWithTag;
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Fee;
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.instrument.Instrument;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.params.*;
import org.knowm.xchange.service.trade.params.HistoryParamsFundingType;
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
import org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan;
import org.knowm.xchange.service.trade.params.WithdrawFundsParams;

public class BlockchainAccountService extends BlockchainAccountServiceRaw
implements AccountService {
Expand Down Expand Up @@ -57,20 +64,6 @@ public AccountInfo getAccountInfo() throws IOException {
}
}

/** Use {@link String withdrawFunds(WithdrawFundsParams params)} instead */
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
throws IOException {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

/** Use {@link String withdrawFunds(WithdrawFundsParams params)} instead */
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, AddressWithTag address)
throws IOException {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

/** For more information see {@link WithdrawFundsParams} */
@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.knowm.xchange.blockchain.service;

import static org.knowm.xchange.blockchain.BlockchainConstants.NOT_IMPLEMENTED_YET;

import java.io.IOException;
import java.util.List;
import org.knowm.xchange.blockchain.BlockchainAdapters;
import org.knowm.xchange.blockchain.BlockchainAuthenticated;
import org.knowm.xchange.blockchain.BlockchainErrorAdapter;
Expand All @@ -12,12 +10,8 @@
import org.knowm.xchange.client.ResilienceRegistries;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.instrument.Instrument;
import org.knowm.xchange.service.marketdata.MarketDataService;
import org.knowm.xchange.service.marketdata.params.Params;

public class BlockchainMarketDataService extends BlockchainMarketDataServiceRaw
implements MarketDataService {
Expand All @@ -29,21 +23,6 @@ public BlockchainMarketDataService(
super(exchange, blockchainApi, resilienceRegistries);
}

@Override
public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

@Override
public Ticker getTicker(Instrument instrument, Object... args) throws IOException {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

@Override
public List<Ticker> getTickers(Params params) {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
try {
Expand All @@ -63,13 +42,4 @@ public OrderBook getOrderBook(Instrument instrument, Object... args) throws IOEx
}
}

@Override
public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

@Override
public Trades getTrades(Instrument instrument, Object... args) throws IOException {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.knowm.xchange.blockchain.service;

import static org.knowm.xchange.blockchain.BlockchainConstants.*;
import static org.knowm.xchange.blockchain.BlockchainConstants.CURRENCY_PAIR_EXCEPTION;
import static org.knowm.xchange.blockchain.BlockchainConstants.REJECTED;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -16,13 +17,26 @@
import org.knowm.xchange.client.ResilienceRegistries;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order;
import org.knowm.xchange.dto.account.OpenPositions;
import org.knowm.xchange.dto.trade.*;
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.MarketOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.dto.trade.StopOrder;
import org.knowm.xchange.dto.trade.UserTrades;
import org.knowm.xchange.exceptions.ExchangeException;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.*;
import org.knowm.xchange.service.trade.params.orders.*;
import org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair;
import org.knowm.xchange.service.trade.params.CancelOrderByIdParams;
import org.knowm.xchange.service.trade.params.CancelOrderParams;
import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair;
import org.knowm.xchange.service.trade.params.TradeHistoryParamLimit;
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
import org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan;
import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.DefaultQueryOrderParam;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;
import org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.OrderQueryParams;

public class BlockchainTradeService extends BlockchainTradeServiceRaw implements TradeService {

Expand Down Expand Up @@ -119,11 +133,6 @@ public Class[] getRequiredCancelOrderParamClasses() {
return new Class[] {CancelOrderByIdParams.class, CancelOrderByCurrencyPair.class};
}

@Override
public OpenPositions getOpenPositions() {
throw new NotYetImplementedForExchangeException(NOT_IMPLEMENTED_YET);
}

@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.ACCOUNT_INFORMATION_JSON;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.ADDRESS;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.ADDRESS_DEPOSIT;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.BENEFICIARY;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.DEPOSIT_FAILURE_JSON;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.DEPOSIT_HISTORY_SUCCESS_JSON;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.DEPOSIT_SUCCESS_JSON;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.FEES_JSON;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.NOT_IMPLEMENTED_YET;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.STATUS_CODE_400;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.STATUS_CODE_401;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.SYMBOL_JSON;
Expand Down Expand Up @@ -41,7 +39,6 @@
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.exceptions.ExchangeException;
import org.knowm.xchange.exceptions.ExchangeSecurityException;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.instrument.Instrument;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.params.HistoryParamsFundingType;
Expand Down Expand Up @@ -76,14 +73,6 @@ public void withdrawFailure() {
assertThat(exception).isInstanceOf(ExchangeSecurityException.class).hasMessage(STATUS_CODE_401);
}

@Test(timeout = 2000)
public void withdrawException() {
Throwable exception = catchThrowable(this::withdrawExcept);
assertThat(exception)
.isInstanceOf(NotYetImplementedForExchangeException.class)
.hasMessage(NOT_IMPLEMENTED_YET);
}

@Test(timeout = 2000)
public void requestDepositAddressSuccess() throws Exception {
String response = requestDeposit(DEPOSIT_SUCCESS_JSON, 200);
Expand Down Expand Up @@ -139,11 +128,6 @@ private String withdraw(String responseFileName, int statusCode) throws IOExcept
return service.withdrawFunds(params);
}

private void withdrawExcept() throws IOException {
stubPost(WITHDRAWAL_SUCCESS_JSON, 200, URL_WITHDRAWALS);
service.withdrawFunds(Currency.BTC, BigDecimal.valueOf(0.005), ADDRESS);
}

private String requestDeposit(String responseFileName, int statusCode) throws IOException {
stubPost(responseFileName, statusCode, URL_DEPOSIT_BY_CURRENCY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
import org.knowm.xchange.dto.Order;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.MarketOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.dto.trade.UserTrade;
import org.knowm.xchange.dto.trade.UserTrades;
import org.knowm.xchange.exceptions.NotAvailableFromExchangeException;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair;
import org.knowm.xchange.service.trade.params.CancelOrderByIdParams;
Expand Down Expand Up @@ -59,20 +57,6 @@ public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
return CexIOAdapters.adaptOpenOrders(cexIOOrderList);
}

@Override
public String placeMarketOrder(MarketOrder marketOrder) throws IOException {
/*
Only in market order!
Presently, the exchange is designed in such way that, depending on the BID/ASK the currency changes
(accordingly, you must specify the amount in another currency)
Example: CurrencyPair.BCH_USD, Order.OrderType.ASK, Amount = 0.02 (BCH)
Example: CurrencyPair.BCH_USD, Order.OrderType.BID, Amount = 20 (USD)
Сurrently cannot be implemented!
*/

throw new NotYetImplementedForExchangeException();
}

@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {
CexIOOrder order = placeCexIOLimitOrder(limitOrder);
Expand Down
Loading

0 comments on commit 0b77a88

Please sign in to comment.