@Test public void testWithLong() throws Exception { String[] directives = new String[] { "mask-number body xx-xx-#" }; List<Row> rows = Arrays.asList( new Row("body", 12345L) ); rows = TestingRig.execute(directives, rows); Assert.assertEquals(1, rows.size()); Assert.assertEquals("xx-xx-5", rows.get(0).getValue("body")); }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { String value = TypeConvertor.toString(row.getValue(idx)); if (value == null) { continue; } row.setValue(idx, maskNumber(value, mask)); } else { row.add(column, new String("")); } } return rows; }
MaskNumber implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { String value = TypeConvertor.toString(row.getValue(idx)); if (value == null) { continue; } row.setValue(idx, maskNumber(value, mask)); } else { row.add(column, new String("")); } } return rows; } }
MaskNumber implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { String value = TypeConvertor.toString(row.getValue(idx)); if (value == null) { continue; } row.setValue(idx, maskNumber(value, mask)); } else { row.add(column, new String("")); } } return rows; }  }
MaskNumber implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { String value = TypeConvertor.toString(row.getValue(idx)); if (value == null) { continue; } row.setValue(idx, maskNumber(value, mask)); } else { row.add(column, new String("")); } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); }
MaskNumber implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { String value = TypeConvertor.toString(row.getValue(idx)); if (value == null) { continue; } row.setValue(idx, maskNumber(value, mask)); } else { row.add(column, new String("")); } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); static final String NAME; static final int MASK_NUMBER; static final int MASK_SHUFFLE; }