@Test public void testConvertRecord() throws DataConversionException { StringSplitterToListConverter converter = new StringSplitterToListConverter(); String delimiter1 = "sep"; WorkUnitState workUnitState1 = new WorkUnitState(); workUnitState1.setProp(ConfigurationKeys.CONVERTER_STRING_SPLITTER_DELIMITER, delimiter1); workUnitState1.setProp(ConfigurationKeys.CONVERTER_STRING_SPLITTER_SHOULD_TRIM_RESULTS, true); converter.init(workUnitState1); String inputRecord1 = "1sep2sepsep"; Iterator<List<String>> recordIterator = converter.convertRecord("", inputRecord1, workUnitState1).iterator(); Assert.assertTrue(recordIterator.hasNext()); List<String> record1 = recordIterator.next(); Assert.assertEquals(record1, Lists.newArrayList("1", "2")); Assert.assertFalse(recordIterator.hasNext()); workUnitState1.setProp(ConfigurationKeys.CONVERTER_STRING_SPLITTER_SHOULD_TRIM_RESULTS, false); converter.init(workUnitState1); recordIterator = converter.convertRecord("", inputRecord1, workUnitState1).iterator(); Assert.assertTrue(recordIterator.hasNext()); record1 = recordIterator.next(); Assert.assertEquals(record1, Lists.newArrayList("1", "2", "", "")); Assert.assertFalse(recordIterator.hasNext()); String delimiter2 = "\n\t"; String inputRecord2 = "1" + delimiter2 + "2" + delimiter2 + " "; WorkUnitState workUnitState2 = new WorkUnitState(); workUnitState2.setProp(ConfigurationKeys.CONVERTER_STRING_SPLITTER_DELIMITER, delimiter2); converter.init(workUnitState2); recordIterator = converter.convertRecord("", inputRecord2, workUnitState2).iterator(); Assert.assertTrue(recordIterator.hasNext()); List<String> record2 = recordIterator.next(); Assert.assertEquals(record2, Lists.newArrayList("1", "2", " ")); Assert.assertFalse(recordIterator.hasNext()); }
@Override public Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit) throws DataConversionException { List<String> convertedRecord = this.shouldTrimResults ? this.splitter.omitEmptyStrings().trimResults().splitToList(inputRecord) : this.splitter.splitToList(inputRecord); return new SingleRecordIterable<>(convertedRecord); }
StringSplitterToListConverter extends Converter<String, String, String, List<String>> { @Override public Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit) throws DataConversionException { List<String> convertedRecord = this.shouldTrimResults ? this.splitter.omitEmptyStrings().trimResults().splitToList(inputRecord) : this.splitter.splitToList(inputRecord); return new SingleRecordIterable<>(convertedRecord); } }
StringSplitterToListConverter extends Converter<String, String, String, List<String>> { @Override public Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit) throws DataConversionException { List<String> convertedRecord = this.shouldTrimResults ? this.splitter.omitEmptyStrings().trimResults().splitToList(inputRecord) : this.splitter.splitToList(inputRecord); return new SingleRecordIterable<>(convertedRecord); }  }
StringSplitterToListConverter extends Converter<String, String, String, List<String>> { @Override public Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit) throws DataConversionException { List<String> convertedRecord = this.shouldTrimResults ? this.splitter.omitEmptyStrings().trimResults().splitToList(inputRecord) : this.splitter.splitToList(inputRecord); return new SingleRecordIterable<>(convertedRecord); }  @Override Converter<String, String, String, List<String>> init(WorkUnitState workUnit); @Override String convertSchema(String inputSchema, WorkUnitState workUnit); @Override Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit); }
StringSplitterToListConverter extends Converter<String, String, String, List<String>> { @Override public Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit) throws DataConversionException { List<String> convertedRecord = this.shouldTrimResults ? this.splitter.omitEmptyStrings().trimResults().splitToList(inputRecord) : this.splitter.splitToList(inputRecord); return new SingleRecordIterable<>(convertedRecord); }  @Override Converter<String, String, String, List<String>> init(WorkUnitState workUnit); @Override String convertSchema(String inputSchema, WorkUnitState workUnit); @Override Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit);  }