WebSocketMessageListener extends AbstractReceiveListener { int closeCode(Throwable e) { if (e instanceof TooManyRequestsException) return WebSocketCloseCodes.TRY_AGAIN_LATER; if (e instanceof BadRequestException) return WebSocketCloseCodes.POLICY_VIOLATION; return WebSocketCloseCodes.INTERNAL_ERROR; } WebSocketMessageListener(LogManager logManager, RateControl rateControl);   }
@Test void closeCode() { assertThat(listener.closeCode(new Error())) .isEqualTo(WebSocketCloseCodes.INTERNAL_ERROR); assertThat(listener.closeCode(new TooManyRequestsException("rate exceeds"))) .isEqualTo(WebSocketCloseCodes.TRY_AGAIN_LATER); assertThat(listener.closeCode(new BadRequestException("bad request"))) .isEqualTo(WebSocketCloseCodes.POLICY_VIOLATION); }