use of org.knowm.xchange.poloniex.dto.PoloniexException in project XChange by knowm.
the class PoloniexErrorAdapterTest method throwIfErrorResponse_unauthorizedStatus.
@Test
public void throwIfErrorResponse_unauthorizedStatus() {
PoloniexException e = new PoloniexException();
e.setError("Some error msg");
e.setHttpStatusCode(403);
ExchangeException adapted = PoloniexErrorAdapter.adapt(e);
assertThat(adapted).isExactlyInstanceOf(ExchangeSecurityException.class);
}
use of org.knowm.xchange.poloniex.dto.PoloniexException in project XChange by knowm.
the class PoloniexAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
try {
Date start = null;
Date end = null;
if (params instanceof TradeHistoryParamsTimeSpan) {
start = ((TradeHistoryParamsTimeSpan) params).getStartTime();
end = ((TradeHistoryParamsTimeSpan) params).getEndTime();
}
final PoloniexDepositsWithdrawalsResponse poloFundings = returnDepositsWithdrawals(start, end);
return PoloniexAdapters.adaptFundingRecords(poloFundings);
} catch (PoloniexException e) {
throw PoloniexErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.poloniex.dto.PoloniexException in project XChange by knowm.
the class PoloniexOrderTest method sellRejectTest.
@Test(expected = PoloniexException.class)
public void sellRejectTest() throws Exception {
InvocationResult invocationResult = new InvocationResult("{\"error\":\"Not enough LTC.\"}", 200);
Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("sell", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class, String.class, String.class, Integer.class, Integer.class, Integer.class);
RestMethodMetadata data = RestMethodMetadata.create(apiMethod, "", "");
try {
new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, data);
} catch (PoloniexException e) {
Assert.assertTrue(e.getMessage().startsWith("Not enough LTC."));
throw e;
}
}
use of org.knowm.xchange.poloniex.dto.PoloniexException in project XChange by knowm.
the class PoloniexOrderTest method moveOrderRejectTest.
@Test(expected = PoloniexException.class)
public void moveOrderRejectTest() throws Exception {
InvocationResult invocationResult = new InvocationResult("{\"success\":0,\"error\":\"Not enough LTC.\"}", 200);
Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("moveOrder", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class, String.class, String.class, Integer.class, Integer.class);
RestMethodMetadata data = RestMethodMetadata.create(apiMethod, "", "");
try {
new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, data);
} catch (PoloniexException e) {
Assert.assertTrue(e.getMessage().startsWith("Not enough LTC."));
throw e;
}
}
use of org.knowm.xchange.poloniex.dto.PoloniexException in project XChange by knowm.
the class PoloniexBalanceTest method balanceRejectTest.
@Test(expected = PoloniexException.class)
public void balanceRejectTest() throws Exception {
InvocationResult invocationResult = new InvocationResult("{\"error\":\"Invalid API key\\/secret pair.\"}", 200);
Method apiMethod = PoloniexAuthenticated.class.getDeclaredMethod("returnCompleteBalances", String.class, ParamsDigest.class, SynchronizedValueFactory.class, String.class);
RestMethodMetadata balances = RestMethodMetadata.create(apiMethod, "", "");
try {
new JacksonResponseReader(new DefaultJacksonObjectMapperFactory().createObjectMapper(), false).read(invocationResult, balances);
} catch (PoloniexException e) {
Assert.assertTrue(e.getMessage().startsWith("Invalid API key/secret pair."));
throw e;
}
}
Aggregations