@Test public void applyWithRetry2() { String jsonString = "{\"database\":cube,\"requestType\":\"SQL\",\"auth\":\"authCode\",\"requestId\":\"93eceaf1-4e47-40a1-84e9-814404eb7ad5\",\"sql\":\"select * from tableA\"}"; JdbcExecutor mockJdbcExecutor = PowerMock.createMock(JdbcExecutor.class); ApiResponse mockApiResponse = PowerMock.createMock(ApiResponse.class); EasyMock.expect(mockApiResponse.isError()).andReturn(true).times(2); EasyMock.expect(mockApiResponse.isError()).andReturn(false).once(); SwiftResponse mockRpcResponse = PowerMock.createMock(SwiftResponse.class); EasyMock.expect(mockRpcResponse.getResult()).andReturn(mockApiResponse).times(3); EasyMock.expect(mockJdbcExecutor.send(EasyMock.notNull(SwiftRequest.class))).andReturn(mockRpcResponse).times(3); PowerMock.replayAll(); new RequestServiceImpl().applyWithRetry(mockJdbcExecutor, jsonString, 3); PowerMock.verifyAll(); }
@Override public ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime) { return applyWithRetry(sender, JdbcJsonBuilder.buildAuthJson(user, password, ""), retryTime); }
RequestServiceImpl implements JdbcRequestService { @Override public ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime) { return applyWithRetry(sender, JdbcJsonBuilder.buildAuthJson(user, password, ""), retryTime); } }
RequestServiceImpl implements JdbcRequestService { @Override public ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime) { return applyWithRetry(sender, JdbcJsonBuilder.buildAuthJson(user, password, ""), retryTime); }  }
RequestServiceImpl implements JdbcRequestService { @Override public ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime) { return applyWithRetry(sender, JdbcJsonBuilder.buildAuthJson(user, password, ""), retryTime); }  @Override ApiResponse apply(JdbcExecutor sender, String user, String password); @Override @SuppressWarnings("unchecked") ApiResponse apply(JdbcExecutor sender, final String requestJson); @Override ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime); @Override @SuppressWarnings("unchecked") ApiResponse applyWithRetry(JdbcExecutor sender, String requestJson, int retryTime); }
RequestServiceImpl implements JdbcRequestService { @Override public ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime) { return applyWithRetry(sender, JdbcJsonBuilder.buildAuthJson(user, password, ""), retryTime); }  @Override ApiResponse apply(JdbcExecutor sender, String user, String password); @Override @SuppressWarnings("unchecked") ApiResponse apply(JdbcExecutor sender, final String requestJson); @Override ApiResponse applyWithRetry(JdbcExecutor sender, String user, String password, int retryTime); @Override @SuppressWarnings("unchecked") ApiResponse applyWithRetry(JdbcExecutor sender, String requestJson, int retryTime);  }