L2FormattingMapper extends Mapper<NullWritable, NullWritable, NullWritable, NullWritable> { static String getNewProductName(String productName, String regex, String replacement) { return productName.replaceAll(regex, replacement); }  @Override void run(Mapper.Context context); static String getProductName(Configuration jobConfig, String fileName);  }
@Test public void testGetNewProductname() throws Exception { assertEquals("MER_RR__1P2000", newName("L2_of_MER_RR__1P2000", "L2_of_(.+)", "$1")); assertEquals("MER_SDR_1P2000", newName("L2_of_MER_RR__1P2000", "L2_of_MER_RR_(.+)", "MER_SDR$1")); assertEquals("MER_RR__1P2000_cc", newName("L2_of_MER_RR__1P2000", "L2_of_(.+)", "$1_cc")); assertEquals("MER_RR__CCL1P_20060708_1234567", newName("L2_of_MER_RR__1PNMAP20060708_1234567", "L2_of_(MER_..._)1.....(.+)", "$1CCL1P_$2")); assertEquals("MER_FSG_CCL1P_20060708_1234567", newName("L2_of_MER_FSG_1PNMAP20060708_1234567", "L2_of_(MER_..._)1.....(.+)", "$1CCL1P_$2")); assertEquals("MER_FSG_SDR_20050708_112233_042", newName("L2_of_MER_FSG_1PNUPA20050708_112233_042", "L2_of_(MER_FSG)_1.....(.+)", "$1_SDR_$2")); assertEquals("CHL_Northsea_BC_20060708_123456", newName("L2_of_MER_RR__1PNMAP20060708_123456_0815", "L2_of_MER_..._1.....(........_......).*", "CHL_Northsea_BC_$1")); }