@Test public void testMapperDate_notParsableDatePattern() { MapDateDescriptorImpl mapDateDescriptor = new MapDateDescriptorImpl(); mapDateDescriptor.setTargetDatePattern("not_parsable_content"); MapperDate mapperDate = new MapperDate(); assertFalse("Was not able to initialize!", mapperDate.init(null, null, "someField", null, mapDateDescriptor)); }
@Override public boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor) { init(inputDesc, fieldName, mapClassCode); String targetDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getTargetDatePattern(); String srcDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getSourceDatePattern(); if (StringUtils.isEmpty(targetDateFormat)) { logger.fatal("Date format for map is empty. " + this); } else { logger.info("Date mapper format is " + targetDateFormat); if (targetDateFormat.equalsIgnoreCase("epoch")) { isEpoch = true; return true; } else { try { targetDateFormatter = FastDateFormat.getInstance(targetDateFormat); if (!StringUtils.isEmpty(srcDateFormat)) { srcDateFormatter = FastDateFormat.getInstance(srcDateFormat); } return true; } catch (Throwable ex) { logger.fatal("Error creating date format. format=" + targetDateFormat + ". " + this.toString()); } } } return false; }
MapperDate extends Mapper<LogFeederProps> { @Override public boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor) { init(inputDesc, fieldName, mapClassCode); String targetDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getTargetDatePattern(); String srcDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getSourceDatePattern(); if (StringUtils.isEmpty(targetDateFormat)) { logger.fatal("Date format for map is empty. " + this); } else { logger.info("Date mapper format is " + targetDateFormat); if (targetDateFormat.equalsIgnoreCase("epoch")) { isEpoch = true; return true; } else { try { targetDateFormatter = FastDateFormat.getInstance(targetDateFormat); if (!StringUtils.isEmpty(srcDateFormat)) { srcDateFormatter = FastDateFormat.getInstance(srcDateFormat); } return true; } catch (Throwable ex) { logger.fatal("Error creating date format. format=" + targetDateFormat + ". " + this.toString()); } } } return false; } }
MapperDate extends Mapper<LogFeederProps> { @Override public boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor) { init(inputDesc, fieldName, mapClassCode); String targetDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getTargetDatePattern(); String srcDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getSourceDatePattern(); if (StringUtils.isEmpty(targetDateFormat)) { logger.fatal("Date format for map is empty. " + this); } else { logger.info("Date mapper format is " + targetDateFormat); if (targetDateFormat.equalsIgnoreCase("epoch")) { isEpoch = true; return true; } else { try { targetDateFormatter = FastDateFormat.getInstance(targetDateFormat); if (!StringUtils.isEmpty(srcDateFormat)) { srcDateFormatter = FastDateFormat.getInstance(srcDateFormat); } return true; } catch (Throwable ex) { logger.fatal("Error creating date format. format=" + targetDateFormat + ". " + this.toString()); } } } return false; }  }
MapperDate extends Mapper<LogFeederProps> { @Override public boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor) { init(inputDesc, fieldName, mapClassCode); String targetDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getTargetDatePattern(); String srcDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getSourceDatePattern(); if (StringUtils.isEmpty(targetDateFormat)) { logger.fatal("Date format for map is empty. " + this); } else { logger.info("Date mapper format is " + targetDateFormat); if (targetDateFormat.equalsIgnoreCase("epoch")) { isEpoch = true; return true; } else { try { targetDateFormatter = FastDateFormat.getInstance(targetDateFormat); if (!StringUtils.isEmpty(srcDateFormat)) { srcDateFormatter = FastDateFormat.getInstance(srcDateFormat); } return true; } catch (Throwable ex) { logger.fatal("Error creating date format. format=" + targetDateFormat + ". " + this.toString()); } } } return false; }  @Override boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor); @Override Object apply(Map<String, Object> jsonObj, Object value); }
MapperDate extends Mapper<LogFeederProps> { @Override public boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor) { init(inputDesc, fieldName, mapClassCode); String targetDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getTargetDatePattern(); String srcDateFormat = ((MapDateDescriptor)mapFieldDescriptor).getSourceDatePattern(); if (StringUtils.isEmpty(targetDateFormat)) { logger.fatal("Date format for map is empty. " + this); } else { logger.info("Date mapper format is " + targetDateFormat); if (targetDateFormat.equalsIgnoreCase("epoch")) { isEpoch = true; return true; } else { try { targetDateFormatter = FastDateFormat.getInstance(targetDateFormat); if (!StringUtils.isEmpty(srcDateFormat)) { srcDateFormatter = FastDateFormat.getInstance(srcDateFormat); } return true; } catch (Throwable ex) { logger.fatal("Error creating date format. format=" + targetDateFormat + ". " + this.toString()); } } } return false; }  @Override boolean init(LogFeederProps logFeederProps, String inputDesc, String fieldName, String mapClassCode, MapFieldDescriptor mapFieldDescriptor); @Override Object apply(Map<String, Object> jsonObj, Object value);  }