BasicIseParser extends BasicParser { @SuppressWarnings("unchecked") @Override public List<JSONObject> parse(byte[] msg) { String raw_message = ""; List<JSONObject> messages = new ArrayList<>(); try { raw_message = new String(msg, getReadCharset()); _LOG.debug("Received message: {}", raw_message); _parser.ReInit(new StringReader("header=" + raw_message.trim())); JSONObject payload = _parser.parseObject(); String ip_src_addr = (String) payload.get("Device IP Address"); String ip_src_port = (String) payload.get("Device Port"); String ip_dst_addr = (String) payload.get("DestinationIPAddress"); String ip_dst_port = (String) payload.get("DestinationPort"); if(ip_src_addr != null) payload.put("ip_src_addr", ip_src_addr); if(ip_src_port != null) payload.put("ip_src_port", ip_src_port); if(ip_dst_addr != null) payload.put("ip_dst_addr", ip_dst_addr); if(ip_dst_port != null) payload.put("ip_dst_port", ip_dst_port); messages.add(payload); return messages; } catch (Exception e) { Log.error(e.toString()); e.printStackTrace(); } return null; }  @Override void configure(Map<String, Object> parserConfig); @Override void init(); @SuppressWarnings("unchecked") @Override List<JSONObject> parse(byte[] msg); @Override boolean validate(JSONObject message);  }
@Test public void testParse() throws org.json.simple.parser.ParseException, IOException, ProcessingException { for (String inputString : inputStrings) { JSONObject parsed = parser.parse(inputString.getBytes(StandardCharsets.UTF_8)).get(0); assertNotNull(parsed); JSONParser parser = new JSONParser(); Map<?, ?> json = (Map<?, ?>) parser.parse(parsed.toJSONString()); assertTrue(validateJsonData(getSchemaJsonString(), json.toString())); } }