PoloniexErrorAdapter { public static ExchangeException adapt(PoloniexException e) { switch (e.getHttpStatusCode()) { case 403: return new ExchangeSecurityException(e); default: return adaptBasedOnErrorMessage(e); } }  static ExchangeException adapt(PoloniexException e);  }
@Test public void throwIfErrorResponse_invalidPair() { PoloniexException e = new PoloniexException(); e.setError("Invalid currency pair"); e.setHttpStatusCode(200); ExchangeException adapted = PoloniexErrorAdapter.adapt(e); assertThat(adapted).isExactlyInstanceOf(CurrencyPairNotValidException.class); }
@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); }
@Test public void throwIfErrorResponse_unrecognizedStatusAndErrorMessage() { PoloniexException e = new PoloniexException(); e.setError("Some error msg"); e.setHttpStatusCode(123); ExchangeException adapted = PoloniexErrorAdapter.adapt(e); assertThat(adapted).isExactlyInstanceOf(ExchangeException.class); }