@Test public void testEmailFormat() throws Exception { NotificationSender sender = new NotificationSender(); ColumnDef old = ColumnDef.builder().index(1) .name("old").type("varchar").build(); ColumnDef newC = ColumnDef.builder().index(1) .name("newName").type("int").build(); Pair<ColumnDef, ColumnDef> p = new Pair<ColumnDef, ColumnDef>(old, newC); FormatChange change = FormatChange.builder() .nameChanges(Lists.newArrayList(p)) .typeChanges(Lists.newArrayList(p)) .newColumns(Lists.newArrayList(newC)) .delimChanged( true ) .escapeStrChanged( true ) .nullStrChanged( true ) .partitonColumnChanged( true ) .build(); List columnList1 = Lists.newArrayList(new ColumnDef("REC_UNIQUE_ID", "BIGINT",0), new ColumnDef("ORGNL_TRADE_DT", "DATE",1), new ColumnDef("MKT_CNTR_ID", "VARCHAR(1)",2), new ColumnDef("MBR_ID", "VARCHAR(4)",3), new ColumnDef("FIRM_MP_ID", "VARCHAR(4)",4), new ColumnDef("FIRM_CRD_NB", "INT",5), new ColumnDef("MBR_CLRG_NB", "VARCHAR(4)",6), new ColumnDef("REC_LOAD_DT", "DATE",7)); List columnList2 = Lists.newArrayList(new ColumnDef("REC_UNIQUE_ID", "BIGINT",0), new ColumnDef("ORGNL_TRADE_DT", "DATE",1), new ColumnDef("MKT_CNTR_ID", "VARCHAR(1)",2), new ColumnDef("MBR_ID", "VARCHAR(4)",3), new ColumnDef("FIRM_MP_ID", "VARCHAR(4)",4), new ColumnDef("FIRM_CRD_NB", "INT",5), new ColumnDef("MBR_CLRG_NB", "VARCHAR(4)",6), new ColumnDef("REC_LOAD_DT", "DATE",7), new ColumnDef("NEW_COLUMN", "VARCHAR(6)",8)); log.info("Email Format (All Changes included):\n{}", sender.getFormatChangeMsg(change, 2, new JobDefinition(1, "ns", "obj", "prc", "txt", "", null, "", ""), HiveTableSchema.builder().columns(columnList1).partitionColumns( columnList1 ).build(), HiveTableSchema.builder().columns(columnList2).partitionColumns( columnList2 ).build()) ); }
protected String getFormatChangeMsg( FormatChange change, int version, JobDefinition job, HiveTableSchema existing, HiveTableSchema newColumns ) throws PebbleException, IOException { PebbleTemplate template = engine.getTemplate( "templates/formatChangeNotificationTemplate.txt" ); Map<String, Object> context = new HashMap<>(); context.put( "changes", change ); context.put( "nameSpace", job.getObjectDefinition().getNameSpace() ); context.put( "tableName", job.getTableName() ); context.put( "version", version ); context.put( "existing", existing ); context.put( "new", newColumns ); StringWriter writer = new StringWriter(); template.evaluate( writer, context ); return writer.toString(); }
NotificationSender { protected String getFormatChangeMsg( FormatChange change, int version, JobDefinition job, HiveTableSchema existing, HiveTableSchema newColumns ) throws PebbleException, IOException { PebbleTemplate template = engine.getTemplate( "templates/formatChangeNotificationTemplate.txt" ); Map<String, Object> context = new HashMap<>(); context.put( "changes", change ); context.put( "nameSpace", job.getObjectDefinition().getNameSpace() ); context.put( "tableName", job.getTableName() ); context.put( "version", version ); context.put( "existing", existing ); context.put( "new", newColumns ); StringWriter writer = new StringWriter(); template.evaluate( writer, context ); return writer.toString(); } }
NotificationSender { protected String getFormatChangeMsg( FormatChange change, int version, JobDefinition job, HiveTableSchema existing, HiveTableSchema newColumns ) throws PebbleException, IOException { PebbleTemplate template = engine.getTemplate( "templates/formatChangeNotificationTemplate.txt" ); Map<String, Object> context = new HashMap<>(); context.put( "changes", change ); context.put( "nameSpace", job.getObjectDefinition().getNameSpace() ); context.put( "tableName", job.getTableName() ); context.put( "version", version ); context.put( "existing", existing ); context.put( "new", newColumns ); StringWriter writer = new StringWriter(); template.evaluate( writer, context ); return writer.toString(); }  }
NotificationSender { protected String getFormatChangeMsg( FormatChange change, int version, JobDefinition job, HiveTableSchema existing, HiveTableSchema newColumns ) throws PebbleException, IOException { PebbleTemplate template = engine.getTemplate( "templates/formatChangeNotificationTemplate.txt" ); Map<String, Object> context = new HashMap<>(); context.put( "changes", change ); context.put( "nameSpace", job.getObjectDefinition().getNameSpace() ); context.put( "tableName", job.getTableName() ); context.put( "version", version ); context.put( "existing", existing ); context.put( "new", newColumns ); StringWriter writer = new StringWriter(); template.evaluate( writer, context ); return writer.toString(); }  void sendFailureEmail( JobDefinition od, int numRetry, String errorLog, String clusterID ); void sendNotificationEmail( String msgBody, String subject, JobDefinition od ); void sendEmail( String msgBody, String subject ); void sendFormatChangeEmail( FormatChange change, int version, JobDefinition job,
									   HiveTableSchema existing, HiveTableSchema newColumns ); }
NotificationSender { protected String getFormatChangeMsg( FormatChange change, int version, JobDefinition job, HiveTableSchema existing, HiveTableSchema newColumns ) throws PebbleException, IOException { PebbleTemplate template = engine.getTemplate( "templates/formatChangeNotificationTemplate.txt" ); Map<String, Object> context = new HashMap<>(); context.put( "changes", change ); context.put( "nameSpace", job.getObjectDefinition().getNameSpace() ); context.put( "tableName", job.getTableName() ); context.put( "version", version ); context.put( "existing", existing ); context.put( "new", newColumns ); StringWriter writer = new StringWriter(); template.evaluate( writer, context ); return writer.toString(); }  void sendFailureEmail( JobDefinition od, int numRetry, String errorLog, String clusterID ); void sendNotificationEmail( String msgBody, String subject, JobDefinition od ); void sendEmail( String msgBody, String subject ); void sendFormatChangeEmail( FormatChange change, int version, JobDefinition job,
									   HiveTableSchema existing, HiveTableSchema newColumns );  }