@Test public void testJSONFilterCode_invalidJson() throws Exception { init(new FilterJsonDescriptorImpl()); String inputStr = "invalid json"; try{ filterJson.apply(inputStr,new InputFileMarker(null, null, 0)); fail("Expected LogFeederException was not occured"); } catch(LogFeederException logFeederException) { assertEquals("Json parsing failed for inputstr = " + inputStr, logFeederException.getLocalizedMessage()); } }
@Override public void apply(String inputStr, InputMarker inputMarker) throws Exception { Map<String, Object> jsonMap = null; try { jsonMap = LogFeederUtil.toJSONObject(inputStr); } catch (Exception e) { logger.error(e.getLocalizedMessage()); throw new LogFeederException("Json parsing failed for inputstr = " + inputStr ,e.getCause()); } Double lineNumberD = (Double) jsonMap.get("line_number"); if (lineNumberD != null) { long lineNumber = lineNumberD.longValue(); jsonMap.put("line_number", lineNumber); } String timeStampStr = (String) jsonMap.get("logtime"); if (timeStampStr != null && !timeStampStr.isEmpty()) { String logtime = DateUtil.getDate(timeStampStr); jsonMap.put("logtime", logtime); jsonMap.put(LogFeederConstants.IN_MEMORY_TIMESTAMP, Long.parseLong(timeStampStr)); } super.apply(jsonMap, inputMarker); }
FilterJSON extends Filter<LogFeederProps> { @Override public void apply(String inputStr, InputMarker inputMarker) throws Exception { Map<String, Object> jsonMap = null; try { jsonMap = LogFeederUtil.toJSONObject(inputStr); } catch (Exception e) { logger.error(e.getLocalizedMessage()); throw new LogFeederException("Json parsing failed for inputstr = " + inputStr ,e.getCause()); } Double lineNumberD = (Double) jsonMap.get("line_number"); if (lineNumberD != null) { long lineNumber = lineNumberD.longValue(); jsonMap.put("line_number", lineNumber); } String timeStampStr = (String) jsonMap.get("logtime"); if (timeStampStr != null && !timeStampStr.isEmpty()) { String logtime = DateUtil.getDate(timeStampStr); jsonMap.put("logtime", logtime); jsonMap.put(LogFeederConstants.IN_MEMORY_TIMESTAMP, Long.parseLong(timeStampStr)); } super.apply(jsonMap, inputMarker); } }
FilterJSON extends Filter<LogFeederProps> { @Override public void apply(String inputStr, InputMarker inputMarker) throws Exception { Map<String, Object> jsonMap = null; try { jsonMap = LogFeederUtil.toJSONObject(inputStr); } catch (Exception e) { logger.error(e.getLocalizedMessage()); throw new LogFeederException("Json parsing failed for inputstr = " + inputStr ,e.getCause()); } Double lineNumberD = (Double) jsonMap.get("line_number"); if (lineNumberD != null) { long lineNumber = lineNumberD.longValue(); jsonMap.put("line_number", lineNumber); } String timeStampStr = (String) jsonMap.get("logtime"); if (timeStampStr != null && !timeStampStr.isEmpty()) { String logtime = DateUtil.getDate(timeStampStr); jsonMap.put("logtime", logtime); jsonMap.put(LogFeederConstants.IN_MEMORY_TIMESTAMP, Long.parseLong(timeStampStr)); } super.apply(jsonMap, inputMarker); }  }
FilterJSON extends Filter<LogFeederProps> { @Override public void apply(String inputStr, InputMarker inputMarker) throws Exception { Map<String, Object> jsonMap = null; try { jsonMap = LogFeederUtil.toJSONObject(inputStr); } catch (Exception e) { logger.error(e.getLocalizedMessage()); throw new LogFeederException("Json parsing failed for inputstr = " + inputStr ,e.getCause()); } Double lineNumberD = (Double) jsonMap.get("line_number"); if (lineNumberD != null) { long lineNumber = lineNumberD.longValue(); jsonMap.put("line_number", lineNumber); } String timeStampStr = (String) jsonMap.get("logtime"); if (timeStampStr != null && !timeStampStr.isEmpty()) { String logtime = DateUtil.getDate(timeStampStr); jsonMap.put("logtime", logtime); jsonMap.put(LogFeederConstants.IN_MEMORY_TIMESTAMP, Long.parseLong(timeStampStr)); } super.apply(jsonMap, inputMarker); }  @Override void apply(String inputStr, InputMarker inputMarker); @Override String getShortDescription(); }
FilterJSON extends Filter<LogFeederProps> { @Override public void apply(String inputStr, InputMarker inputMarker) throws Exception { Map<String, Object> jsonMap = null; try { jsonMap = LogFeederUtil.toJSONObject(inputStr); } catch (Exception e) { logger.error(e.getLocalizedMessage()); throw new LogFeederException("Json parsing failed for inputstr = " + inputStr ,e.getCause()); } Double lineNumberD = (Double) jsonMap.get("line_number"); if (lineNumberD != null) { long lineNumber = lineNumberD.longValue(); jsonMap.put("line_number", lineNumber); } String timeStampStr = (String) jsonMap.get("logtime"); if (timeStampStr != null && !timeStampStr.isEmpty()) { String logtime = DateUtil.getDate(timeStampStr); jsonMap.put("logtime", logtime); jsonMap.put(LogFeederConstants.IN_MEMORY_TIMESTAMP, Long.parseLong(timeStampStr)); } super.apply(jsonMap, inputMarker); }  @Override void apply(String inputStr, InputMarker inputMarker); @Override String getShortDescription();  }