Best SeLion code snippet using com.paypal.selion.grid.servlets.TransferServlet.getResponderClass
Source:TransferServlet.java
...129 */130 private UploadResponder getUploadResponder(TransferContext transferContext) {131 LOGGER.entering(transferContext);132 UploadResponder uploadResponder;133 Class<? extends UploadResponder> uploadResponderClass = getResponderClass(transferContext134 .getHttpServletRequest().getHeader("accept"));135 try {136 uploadResponder = (UploadResponder) uploadResponderClass.getConstructor(new Class[] { TransferContext.class }).newInstance(137 new Object[] { transferContext });138 LOGGER.exiting(uploadResponder);139 return uploadResponder;140 } catch (Exception e) {141 // We cannot do any meaningful operation to handle this; catching exception and returning142 // default responder143 uploadResponder = new JsonUploadResponder(transferContext);144 LOGGER.exiting(uploadResponder);145 return uploadResponder;146 }147 }148 private Class<? extends UploadResponder> getResponderClass(String headerString) {149 String[] headers = headerString.split(";");150 List<String> headerPrecedenceList = Arrays.asList(headers);151 Collections.reverse(headerPrecedenceList);152 for (String header : headerPrecedenceList) {153 try {154 AcceptHeaderEnum acceptHeaderEnum = AcceptHeaderEnum.getAcceptHeaderEnum(header);155 return acceptHeaderEnum.getUploadResponder();156 } catch (ArtifactUploadException exe) {157 // Exception is thrown if there is no implementation; just ignore and iterate until success158 }159 }160 return JsonUploadResponder.class;161 }162}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!