@Test public void testRsuArray(@Mocked JSONObject mockJSONObject) throws XmlUtilsException { new Expectations() {{ XmlUtils.toJSONObject(anyString); result = mockJSONObject; mockJSONObject.has("request"); result = true; mockJSONObject.has("rsus"); result = true; mockJSONObject.get("rsus"); result = new JSONArray(); }}; testAsn1EncodedDataRouter.process("stringthing"); }
@Override public Object process(String consumedData) { try { logger.debug("Consumed: {}", consumedData); JSONObject consumedObj = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); JSONObject metadata = consumedObj.getJSONObject(AppContext.METADATA_STRING); if (metadata.has(TimTransmogrifier.REQUEST_STRING)) { JSONObject request = metadata.getJSONObject(TimTransmogrifier.REQUEST_STRING); if (request.has(TimTransmogrifier.RSUS_STRING)) { JSONObject rsusIn = (JSONObject) request.get(TimTransmogrifier.RSUS_STRING); if (rsusIn.has(TimTransmogrifier.RSUS_STRING)) { Object rsu = rsusIn.get(TimTransmogrifier.RSUS_STRING); JSONArray rsusOut = new JSONArray(); if (rsu instanceof JSONArray) { logger.debug("Multiple RSUs exist in the request: {}", request); JSONArray rsusInArray = (JSONArray) rsu; for (int i = 0; i < rsusInArray.length(); i++) { rsusOut.put(rsusInArray.get(i)); } request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else if (rsu instanceof JSONObject) { logger.debug("Single RSU exists in the request: {}", request); rsusOut.put(rsu); request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else { logger.debug("No RSUs exist in the request: {}", request); request.remove(TimTransmogrifier.RSUS_STRING); } } } ServiceRequest servicerequest = getServicerequest(consumedObj); processEncodedTim(servicerequest, consumedObj); } else { throw new Asn1EncodedDataRouterException("Invalid or missing '" + TimTransmogrifier.REQUEST_STRING + "' object in the encoder response"); } } catch (Exception e) { String msg = "Error in processing received message from ASN.1 Encoder module: " + consumedData; EventLogger.logger.error(msg, e); logger.error(msg, e); } return null; }
Asn1EncodedDataRouter extends AbstractSubscriberProcessor<String, String> { @Override public Object process(String consumedData) { try { logger.debug("Consumed: {}", consumedData); JSONObject consumedObj = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); JSONObject metadata = consumedObj.getJSONObject(AppContext.METADATA_STRING); if (metadata.has(TimTransmogrifier.REQUEST_STRING)) { JSONObject request = metadata.getJSONObject(TimTransmogrifier.REQUEST_STRING); if (request.has(TimTransmogrifier.RSUS_STRING)) { JSONObject rsusIn = (JSONObject) request.get(TimTransmogrifier.RSUS_STRING); if (rsusIn.has(TimTransmogrifier.RSUS_STRING)) { Object rsu = rsusIn.get(TimTransmogrifier.RSUS_STRING); JSONArray rsusOut = new JSONArray(); if (rsu instanceof JSONArray) { logger.debug("Multiple RSUs exist in the request: {}", request); JSONArray rsusInArray = (JSONArray) rsu; for (int i = 0; i < rsusInArray.length(); i++) { rsusOut.put(rsusInArray.get(i)); } request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else if (rsu instanceof JSONObject) { logger.debug("Single RSU exists in the request: {}", request); rsusOut.put(rsu); request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else { logger.debug("No RSUs exist in the request: {}", request); request.remove(TimTransmogrifier.RSUS_STRING); } } } ServiceRequest servicerequest = getServicerequest(consumedObj); processEncodedTim(servicerequest, consumedObj); } else { throw new Asn1EncodedDataRouterException("Invalid or missing '" + TimTransmogrifier.REQUEST_STRING + "' object in the encoder response"); } } catch (Exception e) { String msg = "Error in processing received message from ASN.1 Encoder module: " + consumedData; EventLogger.logger.error(msg, e); logger.error(msg, e); } return null; } }
Asn1EncodedDataRouter extends AbstractSubscriberProcessor<String, String> { @Override public Object process(String consumedData) { try { logger.debug("Consumed: {}", consumedData); JSONObject consumedObj = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); JSONObject metadata = consumedObj.getJSONObject(AppContext.METADATA_STRING); if (metadata.has(TimTransmogrifier.REQUEST_STRING)) { JSONObject request = metadata.getJSONObject(TimTransmogrifier.REQUEST_STRING); if (request.has(TimTransmogrifier.RSUS_STRING)) { JSONObject rsusIn = (JSONObject) request.get(TimTransmogrifier.RSUS_STRING); if (rsusIn.has(TimTransmogrifier.RSUS_STRING)) { Object rsu = rsusIn.get(TimTransmogrifier.RSUS_STRING); JSONArray rsusOut = new JSONArray(); if (rsu instanceof JSONArray) { logger.debug("Multiple RSUs exist in the request: {}", request); JSONArray rsusInArray = (JSONArray) rsu; for (int i = 0; i < rsusInArray.length(); i++) { rsusOut.put(rsusInArray.get(i)); } request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else if (rsu instanceof JSONObject) { logger.debug("Single RSU exists in the request: {}", request); rsusOut.put(rsu); request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else { logger.debug("No RSUs exist in the request: {}", request); request.remove(TimTransmogrifier.RSUS_STRING); } } } ServiceRequest servicerequest = getServicerequest(consumedObj); processEncodedTim(servicerequest, consumedObj); } else { throw new Asn1EncodedDataRouterException("Invalid or missing '" + TimTransmogrifier.REQUEST_STRING + "' object in the encoder response"); } } catch (Exception e) { String msg = "Error in processing received message from ASN.1 Encoder module: " + consumedData; EventLogger.logger.error(msg, e); logger.error(msg, e); } return null; } Asn1EncodedDataRouter(OdeProperties odeProperties); }
Asn1EncodedDataRouter extends AbstractSubscriberProcessor<String, String> { @Override public Object process(String consumedData) { try { logger.debug("Consumed: {}", consumedData); JSONObject consumedObj = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); JSONObject metadata = consumedObj.getJSONObject(AppContext.METADATA_STRING); if (metadata.has(TimTransmogrifier.REQUEST_STRING)) { JSONObject request = metadata.getJSONObject(TimTransmogrifier.REQUEST_STRING); if (request.has(TimTransmogrifier.RSUS_STRING)) { JSONObject rsusIn = (JSONObject) request.get(TimTransmogrifier.RSUS_STRING); if (rsusIn.has(TimTransmogrifier.RSUS_STRING)) { Object rsu = rsusIn.get(TimTransmogrifier.RSUS_STRING); JSONArray rsusOut = new JSONArray(); if (rsu instanceof JSONArray) { logger.debug("Multiple RSUs exist in the request: {}", request); JSONArray rsusInArray = (JSONArray) rsu; for (int i = 0; i < rsusInArray.length(); i++) { rsusOut.put(rsusInArray.get(i)); } request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else if (rsu instanceof JSONObject) { logger.debug("Single RSU exists in the request: {}", request); rsusOut.put(rsu); request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else { logger.debug("No RSUs exist in the request: {}", request); request.remove(TimTransmogrifier.RSUS_STRING); } } } ServiceRequest servicerequest = getServicerequest(consumedObj); processEncodedTim(servicerequest, consumedObj); } else { throw new Asn1EncodedDataRouterException("Invalid or missing '" + TimTransmogrifier.REQUEST_STRING + "' object in the encoder response"); } } catch (Exception e) { String msg = "Error in processing received message from ASN.1 Encoder module: " + consumedData; EventLogger.logger.error(msg, e); logger.error(msg, e); } return null; } Asn1EncodedDataRouter(OdeProperties odeProperties); @Override Object process(String consumedData); ServiceRequest getServicerequest(JSONObject consumedObj); void processEncodedTim(ServiceRequest request, JSONObject consumedObj); void processEncodedTimUnsecured(ServiceRequest request, JSONObject consumedObj); }
Asn1EncodedDataRouter extends AbstractSubscriberProcessor<String, String> { @Override public Object process(String consumedData) { try { logger.debug("Consumed: {}", consumedData); JSONObject consumedObj = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); JSONObject metadata = consumedObj.getJSONObject(AppContext.METADATA_STRING); if (metadata.has(TimTransmogrifier.REQUEST_STRING)) { JSONObject request = metadata.getJSONObject(TimTransmogrifier.REQUEST_STRING); if (request.has(TimTransmogrifier.RSUS_STRING)) { JSONObject rsusIn = (JSONObject) request.get(TimTransmogrifier.RSUS_STRING); if (rsusIn.has(TimTransmogrifier.RSUS_STRING)) { Object rsu = rsusIn.get(TimTransmogrifier.RSUS_STRING); JSONArray rsusOut = new JSONArray(); if (rsu instanceof JSONArray) { logger.debug("Multiple RSUs exist in the request: {}", request); JSONArray rsusInArray = (JSONArray) rsu; for (int i = 0; i < rsusInArray.length(); i++) { rsusOut.put(rsusInArray.get(i)); } request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else if (rsu instanceof JSONObject) { logger.debug("Single RSU exists in the request: {}", request); rsusOut.put(rsu); request.put(TimTransmogrifier.RSUS_STRING, rsusOut); } else { logger.debug("No RSUs exist in the request: {}", request); request.remove(TimTransmogrifier.RSUS_STRING); } } } ServiceRequest servicerequest = getServicerequest(consumedObj); processEncodedTim(servicerequest, consumedObj); } else { throw new Asn1EncodedDataRouterException("Invalid or missing '" + TimTransmogrifier.REQUEST_STRING + "' object in the encoder response"); } } catch (Exception e) { String msg = "Error in processing received message from ASN.1 Encoder module: " + consumedData; EventLogger.logger.error(msg, e); logger.error(msg, e); } return null; } Asn1EncodedDataRouter(OdeProperties odeProperties); @Override Object process(String consumedData); ServiceRequest getServicerequest(JSONObject consumedObj); void processEncodedTim(ServiceRequest request, JSONObject consumedObj); void processEncodedTimUnsecured(ServiceRequest request, JSONObject consumedObj);  }