@Test public void testUUIDGeneration() throws Exception { String[] directives = new String[] { "generate-uuid uuid", }; List<Row> rows = Arrays.asList( new Row("value", "abc"), new Row("value", "xyz"), new Row("value", "Should be fine") ); rows = TestingRig.execute(directives, rows); Assert.assertTrue(rows.size() == 3); Assert.assertEquals(2, rows.get(0).width()); Assert.assertEquals("uuid", rows.get(1).getColumn(1)); Assert.assertEquals("Should be fine", rows.get(2).getValue("value")); }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); UUID uuid = new UUID(random.nextLong(), random.nextLong()); if (idx != -1) { row.setValue(idx, uuid.toString()); } else { row.add(column, uuid.toString()); } } return rows; }
GenerateUUID implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); UUID uuid = new UUID(random.nextLong(), random.nextLong()); if (idx != -1) { row.setValue(idx, uuid.toString()); } else { row.add(column, uuid.toString()); } } return rows; } }
GenerateUUID implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); UUID uuid = new UUID(random.nextLong(), random.nextLong()); if (idx != -1) { row.setValue(idx, uuid.toString()); } else { row.add(column, uuid.toString()); } } return rows; }  }
GenerateUUID implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); UUID uuid = new UUID(random.nextLong(), random.nextLong()); if (idx != -1) { row.setValue(idx, uuid.toString()); } else { row.add(column, uuid.toString()); } } 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(); }
GenerateUUID implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); UUID uuid = new UUID(random.nextLong(), random.nextLong()); if (idx != -1) { row.setValue(idx, uuid.toString()); } else { row.add(column, uuid.toString()); } } 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; }