@Test public void testSendToRsus(@Mocked OdeTravelerInputData mockOdeTravelerInputData) throws DdsRequestManagerException, IOException, ParseException { new Expectations() { { mockOdeTravelerInputData.getRequest().getRsus(); result = new RSU[] { new RSU() }; SnmpSession.createAndSend(null, null, anyString, (RequestVerb) any); times = 1; } }; testAsn1CommandManager.sendToRsus(mockOdeTravelerInputData.getRequest(), "message"); }
public Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg) { HashMap<String, String> responseList = new HashMap<>(); for (RSU curRsu : request.getRsus()) { TimTransmogrifier.updateRsuCreds(curRsu, odeProperties); ResponseEvent rsuResponse = null; String httpResponseStatus; try { rsuResponse = SnmpSession.createAndSend(request.getSnmp(), curRsu, encodedMsg, request.getOde().getVerb()); if (null == rsuResponse || null == rsuResponse.getResponse()) { httpResponseStatus = "Timeout"; } else if (rsuResponse.getResponse().getErrorStatus() == 0) { httpResponseStatus = "Success"; } else if (rsuResponse.getResponse().getErrorStatus() == 5) { httpResponseStatus = "Message already exists at ".concat(Integer.toString(curRsu.getRsuIndex())); } else { httpResponseStatus = "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText(); } } catch (IOException | ParseException e) { String msg = "Exception caught in TIM RSU deposit loop."; EventLogger.logger.error(msg, e); logger.error(msg, e); httpResponseStatus = e.getClass().getName() + ": " + e.getMessage(); } responseList.put(curRsu.getRsuTarget(), httpResponseStatus); if (null == rsuResponse || null == rsuResponse.getResponse()) { logger.error("Error on RSU SNMP deposit to {}: timed out.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 0) { logger.info("RSU SNMP deposit to {} successful.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 5) { Integer destIndex = curRsu.getRsuIndex(); logger.error("Error on RSU SNMP deposit to {}: message already exists at index {}.", curRsu.getRsuTarget(), destIndex); } else { logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText()); } } return responseList; }
Asn1CommandManager { public Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg) { HashMap<String, String> responseList = new HashMap<>(); for (RSU curRsu : request.getRsus()) { TimTransmogrifier.updateRsuCreds(curRsu, odeProperties); ResponseEvent rsuResponse = null; String httpResponseStatus; try { rsuResponse = SnmpSession.createAndSend(request.getSnmp(), curRsu, encodedMsg, request.getOde().getVerb()); if (null == rsuResponse || null == rsuResponse.getResponse()) { httpResponseStatus = "Timeout"; } else if (rsuResponse.getResponse().getErrorStatus() == 0) { httpResponseStatus = "Success"; } else if (rsuResponse.getResponse().getErrorStatus() == 5) { httpResponseStatus = "Message already exists at ".concat(Integer.toString(curRsu.getRsuIndex())); } else { httpResponseStatus = "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText(); } } catch (IOException | ParseException e) { String msg = "Exception caught in TIM RSU deposit loop."; EventLogger.logger.error(msg, e); logger.error(msg, e); httpResponseStatus = e.getClass().getName() + ": " + e.getMessage(); } responseList.put(curRsu.getRsuTarget(), httpResponseStatus); if (null == rsuResponse || null == rsuResponse.getResponse()) { logger.error("Error on RSU SNMP deposit to {}: timed out.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 0) { logger.info("RSU SNMP deposit to {} successful.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 5) { Integer destIndex = curRsu.getRsuIndex(); logger.error("Error on RSU SNMP deposit to {}: message already exists at index {}.", curRsu.getRsuTarget(), destIndex); } else { logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText()); } } return responseList; } }
Asn1CommandManager { public Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg) { HashMap<String, String> responseList = new HashMap<>(); for (RSU curRsu : request.getRsus()) { TimTransmogrifier.updateRsuCreds(curRsu, odeProperties); ResponseEvent rsuResponse = null; String httpResponseStatus; try { rsuResponse = SnmpSession.createAndSend(request.getSnmp(), curRsu, encodedMsg, request.getOde().getVerb()); if (null == rsuResponse || null == rsuResponse.getResponse()) { httpResponseStatus = "Timeout"; } else if (rsuResponse.getResponse().getErrorStatus() == 0) { httpResponseStatus = "Success"; } else if (rsuResponse.getResponse().getErrorStatus() == 5) { httpResponseStatus = "Message already exists at ".concat(Integer.toString(curRsu.getRsuIndex())); } else { httpResponseStatus = "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText(); } } catch (IOException | ParseException e) { String msg = "Exception caught in TIM RSU deposit loop."; EventLogger.logger.error(msg, e); logger.error(msg, e); httpResponseStatus = e.getClass().getName() + ": " + e.getMessage(); } responseList.put(curRsu.getRsuTarget(), httpResponseStatus); if (null == rsuResponse || null == rsuResponse.getResponse()) { logger.error("Error on RSU SNMP deposit to {}: timed out.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 0) { logger.info("RSU SNMP deposit to {} successful.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 5) { Integer destIndex = curRsu.getRsuIndex(); logger.error("Error on RSU SNMP deposit to {}: message already exists at index {}.", curRsu.getRsuTarget(), destIndex); } else { logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText()); } } return responseList; } Asn1CommandManager(OdeProperties odeProperties); }
Asn1CommandManager { public Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg) { HashMap<String, String> responseList = new HashMap<>(); for (RSU curRsu : request.getRsus()) { TimTransmogrifier.updateRsuCreds(curRsu, odeProperties); ResponseEvent rsuResponse = null; String httpResponseStatus; try { rsuResponse = SnmpSession.createAndSend(request.getSnmp(), curRsu, encodedMsg, request.getOde().getVerb()); if (null == rsuResponse || null == rsuResponse.getResponse()) { httpResponseStatus = "Timeout"; } else if (rsuResponse.getResponse().getErrorStatus() == 0) { httpResponseStatus = "Success"; } else if (rsuResponse.getResponse().getErrorStatus() == 5) { httpResponseStatus = "Message already exists at ".concat(Integer.toString(curRsu.getRsuIndex())); } else { httpResponseStatus = "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText(); } } catch (IOException | ParseException e) { String msg = "Exception caught in TIM RSU deposit loop."; EventLogger.logger.error(msg, e); logger.error(msg, e); httpResponseStatus = e.getClass().getName() + ": " + e.getMessage(); } responseList.put(curRsu.getRsuTarget(), httpResponseStatus); if (null == rsuResponse || null == rsuResponse.getResponse()) { logger.error("Error on RSU SNMP deposit to {}: timed out.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 0) { logger.info("RSU SNMP deposit to {} successful.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 5) { Integer destIndex = curRsu.getRsuIndex(); logger.error("Error on RSU SNMP deposit to {}: message already exists at index {}.", curRsu.getRsuTarget(), destIndex); } else { logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText()); } } return responseList; } Asn1CommandManager(OdeProperties odeProperties); void depositToSdw(String asdBytes); Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg); String sendForSignature(String message); String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg); static ArrayNode buildEncodings(); String getDepositTopic(); void setDepositTopic(String depositTopic); }
Asn1CommandManager { public Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg) { HashMap<String, String> responseList = new HashMap<>(); for (RSU curRsu : request.getRsus()) { TimTransmogrifier.updateRsuCreds(curRsu, odeProperties); ResponseEvent rsuResponse = null; String httpResponseStatus; try { rsuResponse = SnmpSession.createAndSend(request.getSnmp(), curRsu, encodedMsg, request.getOde().getVerb()); if (null == rsuResponse || null == rsuResponse.getResponse()) { httpResponseStatus = "Timeout"; } else if (rsuResponse.getResponse().getErrorStatus() == 0) { httpResponseStatus = "Success"; } else if (rsuResponse.getResponse().getErrorStatus() == 5) { httpResponseStatus = "Message already exists at ".concat(Integer.toString(curRsu.getRsuIndex())); } else { httpResponseStatus = "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText(); } } catch (IOException | ParseException e) { String msg = "Exception caught in TIM RSU deposit loop."; EventLogger.logger.error(msg, e); logger.error(msg, e); httpResponseStatus = e.getClass().getName() + ": " + e.getMessage(); } responseList.put(curRsu.getRsuTarget(), httpResponseStatus); if (null == rsuResponse || null == rsuResponse.getResponse()) { logger.error("Error on RSU SNMP deposit to {}: timed out.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 0) { logger.info("RSU SNMP deposit to {} successful.", curRsu.getRsuTarget()); } else if (rsuResponse.getResponse().getErrorStatus() == 5) { Integer destIndex = curRsu.getRsuIndex(); logger.error("Error on RSU SNMP deposit to {}: message already exists at index {}.", curRsu.getRsuTarget(), destIndex); } else { logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code " + rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText()); } } return responseList; } Asn1CommandManager(OdeProperties odeProperties); void depositToSdw(String asdBytes); Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg); String sendForSignature(String message); String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg); static ArrayNode buildEncodings(); String getDepositTopic(); void setDepositTopic(String depositTopic); static final String ADVISORY_SITUATION_DATA_STRING; }