@Test public void test() throws Exception { SwiftMetaData metaData = Mockito.mock(SwiftMetaData.class); Mockito.when(metaData.getColumnIndex("test")).thenReturn(1); JsonColumnSplitRule splitRule = new JsonColumnSplitRule("test", metaData); String json = "{\"id\":\"2\",\"score\":99,\"age\":28}"; Row row = new ListBasedRow(json); JsonSubRow jsonSubRow = splitRule.split(row); Map<String, Object> result = jsonSubRow.getSubRow(); Assert.assertEquals(result.size(), 3); Assert.assertEquals(result.get("test.id"), "2"); Assert.assertEquals(result.get("test.score"), 99); Assert.assertEquals(result.get("test.age"), 28); }
@Override public JsonSubRow split(Row row) throws Exception { String json = row.getValue(columnIndex - 1); Map<String, Object> splitResult = JsonBuilder.readValue(json, Map.class); return new JsonSubRow(splitColumn, splitResult); }
JsonColumnSplitRule implements ColumnSplitRule<Row, JsonSubRow> { @Override public JsonSubRow split(Row row) throws Exception { String json = row.getValue(columnIndex - 1); Map<String, Object> splitResult = JsonBuilder.readValue(json, Map.class); return new JsonSubRow(splitColumn, splitResult); } }
JsonColumnSplitRule implements ColumnSplitRule<Row, JsonSubRow> { @Override public JsonSubRow split(Row row) throws Exception { String json = row.getValue(columnIndex - 1); Map<String, Object> splitResult = JsonBuilder.readValue(json, Map.class); return new JsonSubRow(splitColumn, splitResult); } JsonColumnSplitRule(String splitColumn, SwiftMetaData baseMetadata); }
JsonColumnSplitRule implements ColumnSplitRule<Row, JsonSubRow> { @Override public JsonSubRow split(Row row) throws Exception { String json = row.getValue(columnIndex - 1); Map<String, Object> splitResult = JsonBuilder.readValue(json, Map.class); return new JsonSubRow(splitColumn, splitResult); } JsonColumnSplitRule(String splitColumn, SwiftMetaData baseMetadata); @Override JsonSubRow split(Row row); }
JsonColumnSplitRule implements ColumnSplitRule<Row, JsonSubRow> { @Override public JsonSubRow split(Row row) throws Exception { String json = row.getValue(columnIndex - 1); Map<String, Object> splitResult = JsonBuilder.readValue(json, Map.class); return new JsonSubRow(splitColumn, splitResult); } JsonColumnSplitRule(String splitColumn, SwiftMetaData baseMetadata); @Override JsonSubRow split(Row row);  }