### Question:
AtmosServerErrorRetryHandler implements HttpRetryHandler { public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (command.getFailureCount() > retryCountLimit) { return false; } if (response.getStatusCode() == 500) { byte[] content = HttpUtils.closeClientButKeepContentStream(response); if (content != null) { try { AtmosError error = utils.parseAtmosErrorFromContent(command, response, new String(content)); if (error.getCode() == AtmosErrorCode.SERVER_BUSY.getCode()) { return backoffHandler.shouldRetryRequest(command, response); } command.incrementFailureCount(); } catch (HttpException e) { logger.warn(e, "error parsing response: %s", new String(content)); } } else { command.incrementFailureCount(); } return false; } return false; } @Inject  AtmosServerErrorRetryHandler(BackoffLimitedRetryHandler backoffHandler,
            AtmosUtils utils); boolean shouldRetryRequest(HttpCommand command, HttpResponse response);  }### Answer:
@Test public void testGet500WithoutError() { AtmosUtils utils = createMock(AtmosUtils.class); BackoffLimitedRetryHandler backoffLimitedRetryHandler = createMock(BackoffLimitedRetryHandler.class); HttpCommand command = createMock(HttpCommand.class); expect(command.getFailureCount()).andReturn(0).once(); expect(command.incrementFailureCount()).andReturn(1).once(); replay(utils, backoffLimitedRetryHandler, command); AtmosServerErrorRetryHandler retry = new AtmosServerErrorRetryHandler(backoffLimitedRetryHandler, utils); assertFalse(retry.shouldRetryRequest(command, HttpResponse.builder().statusCode(500).build())); verify(utils, backoffLimitedRetryHandler, command); }
@Test public void testGet500WithError1040() { AtmosUtils utils = createMock(AtmosUtils.class); BackoffLimitedRetryHandler backoffLimitedRetryHandler = createMock(BackoffLimitedRetryHandler.class); HttpCommand command = createMock(HttpCommand.class); String content = String.format(HTTP_MESSAGE_FORMAT, 1040, "The server is busy. Please try again"); HttpResponse response = HttpResponse.builder().statusCode(500).payload(content).build(); expect(command.getFailureCount()).andReturn(0).once(); expect(utils.parseAtmosErrorFromContent(command, response, content)).andReturn(new AtmosError(1040, "The server is busy. Please try again")).once(); expect(backoffLimitedRetryHandler.shouldRetryRequest(command, response)).andReturn(true).once(); replay(utils, backoffLimitedRetryHandler, command); AtmosServerErrorRetryHandler retry = new AtmosServerErrorRetryHandler(backoffLimitedRetryHandler, utils); assertTrue(retry.shouldRetryRequest(command, response)); verify(utils, backoffLimitedRetryHandler, command); }