@Test public void testParseMessageResponse() { System.out.println("parseMessageResponse"); GatewayRequest message = null; String gatewayResponse = ""; GatewayRequest expResult = null; Set<GatewayResponse> result = instance.parseMessageResponse(message, gatewayResponse); assertEquals(expResult, result); }
public Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse) { logger.debug("Parsing message gateway response"); logger.debug(gatewayResponse); if(message == null) return null; if(gatewayResponse.trim().isEmpty()) return null; Set<GatewayResponse> responses = new HashSet<GatewayResponse>(); String[] responseLines = gatewayResponse.trim().split("\n"); for(String line : responseLines){ String[] responseParts = line.split(" "); if(responseParts[0].equalsIgnoreCase("ID:")){ GatewayResponse response = getCoreManager().createGatewayResponse(); response.setGatewayMessageId(responseParts[1]); response.setRequestId(message.getRequestId()); response.setMessageStatus(MStatus.PENDING); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); if(responseParts.length == 4) response.setRecipientNumber(responseParts[3]); else response.setRecipientNumber(message.getRecipientsNumber()); responses.add(response); } else{ logger.error("Gateway returned error: " + gatewayResponse); String errorCode = responseParts[1]; MStatus status = lookupResponse(errorCode.replaceAll(",", "").trim()); GatewayResponse response = getCoreManager().createGatewayResponse(); response.setRequestId(message.getRequestId()); response.setMessageStatus(status); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); responses.add(response); } } logger.debug(responses); return responses; }
ClickatellGatewayMessageHandlerImpl implements GatewayMessageHandler { public Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse) { logger.debug("Parsing message gateway response"); logger.debug(gatewayResponse); if(message == null) return null; if(gatewayResponse.trim().isEmpty()) return null; Set<GatewayResponse> responses = new HashSet<GatewayResponse>(); String[] responseLines = gatewayResponse.trim().split("\n"); for(String line : responseLines){ String[] responseParts = line.split(" "); if(responseParts[0].equalsIgnoreCase("ID:")){ GatewayResponse response = getCoreManager().createGatewayResponse(); response.setGatewayMessageId(responseParts[1]); response.setRequestId(message.getRequestId()); response.setMessageStatus(MStatus.PENDING); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); if(responseParts.length == 4) response.setRecipientNumber(responseParts[3]); else response.setRecipientNumber(message.getRecipientsNumber()); responses.add(response); } else{ logger.error("Gateway returned error: " + gatewayResponse); String errorCode = responseParts[1]; MStatus status = lookupResponse(errorCode.replaceAll(",", "").trim()); GatewayResponse response = getCoreManager().createGatewayResponse(); response.setRequestId(message.getRequestId()); response.setMessageStatus(status); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); responses.add(response); } } logger.debug(responses); return responses; } }
ClickatellGatewayMessageHandlerImpl implements GatewayMessageHandler { public Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse) { logger.debug("Parsing message gateway response"); logger.debug(gatewayResponse); if(message == null) return null; if(gatewayResponse.trim().isEmpty()) return null; Set<GatewayResponse> responses = new HashSet<GatewayResponse>(); String[] responseLines = gatewayResponse.trim().split("\n"); for(String line : responseLines){ String[] responseParts = line.split(" "); if(responseParts[0].equalsIgnoreCase("ID:")){ GatewayResponse response = getCoreManager().createGatewayResponse(); response.setGatewayMessageId(responseParts[1]); response.setRequestId(message.getRequestId()); response.setMessageStatus(MStatus.PENDING); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); if(responseParts.length == 4) response.setRecipientNumber(responseParts[3]); else response.setRecipientNumber(message.getRecipientsNumber()); responses.add(response); } else{ logger.error("Gateway returned error: " + gatewayResponse); String errorCode = responseParts[1]; MStatus status = lookupResponse(errorCode.replaceAll(",", "").trim()); GatewayResponse response = getCoreManager().createGatewayResponse(); response.setRequestId(message.getRequestId()); response.setMessageStatus(status); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); responses.add(response); } } logger.debug(responses); return responses; }  }
ClickatellGatewayMessageHandlerImpl implements GatewayMessageHandler { public Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse) { logger.debug("Parsing message gateway response"); logger.debug(gatewayResponse); if(message == null) return null; if(gatewayResponse.trim().isEmpty()) return null; Set<GatewayResponse> responses = new HashSet<GatewayResponse>(); String[] responseLines = gatewayResponse.trim().split("\n"); for(String line : responseLines){ String[] responseParts = line.split(" "); if(responseParts[0].equalsIgnoreCase("ID:")){ GatewayResponse response = getCoreManager().createGatewayResponse(); response.setGatewayMessageId(responseParts[1]); response.setRequestId(message.getRequestId()); response.setMessageStatus(MStatus.PENDING); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); if(responseParts.length == 4) response.setRecipientNumber(responseParts[3]); else response.setRecipientNumber(message.getRecipientsNumber()); responses.add(response); } else{ logger.error("Gateway returned error: " + gatewayResponse); String errorCode = responseParts[1]; MStatus status = lookupResponse(errorCode.replaceAll(",", "").trim()); GatewayResponse response = getCoreManager().createGatewayResponse(); response.setRequestId(message.getRequestId()); response.setMessageStatus(status); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); responses.add(response); } } logger.debug(responses); return responses; }  Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse); MStatus parseMessageStatus(String gatewayResponse); MStatus lookupStatus(String code); MStatus lookupResponse(String code); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); Map<MStatus, String> getCodeStatusMap(); void setCodeStatusMap(Map<MStatus, String> codeStatusMap); Map<MStatus, String> getCodeResponseMap(); void setCodeResponseMap(Map<MStatus, String> codeResponseMap); }
ClickatellGatewayMessageHandlerImpl implements GatewayMessageHandler { public Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse) { logger.debug("Parsing message gateway response"); logger.debug(gatewayResponse); if(message == null) return null; if(gatewayResponse.trim().isEmpty()) return null; Set<GatewayResponse> responses = new HashSet<GatewayResponse>(); String[] responseLines = gatewayResponse.trim().split("\n"); for(String line : responseLines){ String[] responseParts = line.split(" "); if(responseParts[0].equalsIgnoreCase("ID:")){ GatewayResponse response = getCoreManager().createGatewayResponse(); response.setGatewayMessageId(responseParts[1]); response.setRequestId(message.getRequestId()); response.setMessageStatus(MStatus.PENDING); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); if(responseParts.length == 4) response.setRecipientNumber(responseParts[3]); else response.setRecipientNumber(message.getRecipientsNumber()); responses.add(response); } else{ logger.error("Gateway returned error: " + gatewayResponse); String errorCode = responseParts[1]; MStatus status = lookupResponse(errorCode.replaceAll(",", "").trim()); GatewayResponse response = getCoreManager().createGatewayResponse(); response.setRequestId(message.getRequestId()); response.setMessageStatus(status); response.setGatewayRequest(message); response.setResponseText(gatewayResponse); response.setDateCreated(new Date()); responses.add(response); } } logger.debug(responses); return responses; }  Set<GatewayResponse> parseMessageResponse(GatewayRequest message, String gatewayResponse); MStatus parseMessageStatus(String gatewayResponse); MStatus lookupStatus(String code); MStatus lookupResponse(String code); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); Map<MStatus, String> getCodeStatusMap(); void setCodeStatusMap(Map<MStatus, String> codeStatusMap); Map<MStatus, String> getCodeResponseMap(); void setCodeResponseMap(Map<MStatus, String> codeResponseMap);  }