CsvImportColumnImpl implements CsvImportColumn, Serializable { @Override public Object getValue(final Object rawValue, final CsvValueAdapter adapter, final CsvImpExTuple tuple) { final String value; if (rawValue == null) { value = null; } else { value = String.valueOf(rawValue); } return getValue(value, adapter, tuple); } CsvImportColumnImpl();  CsvImportColumnImpl(final int columnIndex, final String fieldType,
                               final String name, final String valueRegEx, final String lookupQuery); @Override int getGroupCount(final String rawValue); @Override List getValues(final String rawValue, final CsvValueAdapter adapter, final CsvImportTuple tuple); @Override Object getValue(final Object rawValue, final CsvValueAdapter adapter, final CsvImpExTuple tuple); @Override Object getValue(final String rawValue, final CsvValueAdapter adapter, final CsvImportTuple tuple); @Override int getColumnIndex(); void setColumnIndex(final int columnIndex); @Override String getFieldType(); void setFieldType(final String fieldType); @Override String getDataType(); void setDataType(final String dataType); @Override String getName(); void setName(final String name); @Override String getValueRegEx(); void setValueRegEx(final String valueRegEx); @Override Integer getValueRegExGroup(); void setValueRegExGroup(final Integer valueRegExGroup); @Override String getValueRegExTemplate(); void setValueRegExTemplate(final String valueRegExTemplate); @Override String getLookupQuery(); void setLookupQuery(final String lookupQuery); @Override CsvImportDescriptor getDescriptor(); void setDescriptor(CsvImportDescriptor descriptor); @Override CsvImportDescriptor getParentDescriptor(); @Override void setParentDescriptor(final CsvImportDescriptor parentDescriptor); @Override boolean isUseMasterObject(); @Override void setUseMasterObject(final boolean useMasterObject); @Override boolean isInsertOnly(); @Override void setInsertOnly(final boolean insertOnly); @Override boolean isUpdateOnly(); @Override void setUpdateOnly(final boolean updateOnly); @Override boolean isSkipUpdateForUnresolved(); @Override void setSkipUpdateForUnresolved(final boolean skipUpdateForUnresolved); @Override String getValueConstant(); void setValueConstant(final String valueConstant); @Override String getEntityType(); void setEntityType(final String entityType); @Override String getLanguage(); void setLanguage(final String language); @Override String getContext(); void setContext(final String context); @Override String toString();  }
@Test public void testGetValue() { final CsvValueAdapter adapter = (rawValue, requiredType, impExColumn, tuple) -> rawValue; String reExpKey = "((\\D?\\S{4,}){1,}).*-?.*"; String reExpValue = ".*-.*\\s{1,}((\\D?\\S{4,}){1,})\\s{0,}.*"; CsvImportColumnImpl column = new CsvImportColumnImpl(); CsvImportTupleImpl tuple = new CsvImportTupleImpl("file", 1, new String[0]); assertNull(column.getValue(null, adapter, tuple)); String rawValue = "rawValue"; assertEquals(rawValue, column.getValue(rawValue, adapter, tuple)); column.setValueRegEx("(.*)"); assertEquals(rawValue, column.getValue(rawValue, adapter, tuple)); column.setValueRegEx("(raw)"); assertEquals("raw", column.getValue(rawValue, adapter, tuple)); column.setValueRegEx("(Value)"); assertEquals("Value", column.getValue(rawValue, adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("SomeKey", column.getValue("SomeKey - Value", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("Ключик", column.getValue("Ключик - Значение", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("Ключик", column.getValue(" Ключик - Значение", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals(getprops(), "result", column.getValue("as фыф result - шум 34 123.56 значение sd ыв #", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("результат", column.getValue("as фыф результат - шум 34 123.56 значение sd ыв #", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("Діамант жовтий", column.getValue("фыв 3 фвк Діамант жовтий 3/ 6 - 0,10 Ct", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("Кубічний цирконій", column.getValue("2 Кубічний цирконій - 66 шт", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("Онікс,перли,кварц димчастий", column.getValue("0 Онікс,перли,кварц димчастий - гр", adapter, tuple)); column.setValueRegEx(reExpKey); assertEquals("Онікс", column.getValue("Онікс -", adapter, tuple)); column.setValueRegEx(".*\\s{0,}\\-\\s{0,}(Value)"); assertEquals("Value", column.getValue("SomeKey - ValueZZZ", adapter, tuple)); column.setValueRegEx(reExpValue); assertEquals("Value", column.getValue("SomeKey - Value", adapter, tuple)); column.setValueRegEx(reExpValue); assertEquals("Значение", column.getValue(" Ключ - Значение", adapter, tuple)); column.setValueRegEx(reExpValue); assertEquals("значение", column.getValue("as фыф результат-шум 34 123.56 значение sd ыв #", adapter, tuple)); column.setValueRegEx(".*\\b([a-z]{3,})\\b.*"); assertEquals("word", column.getValue("1234sdcvdfv hfkdf34 word 2134", adapter, tuple)); column.setValueRegExTemplate("My '$1'"); assertEquals("My 'word'", column.getValue("1234sdcvdfv hfkdf34 word 2134", adapter, tuple)); column.setValueRegExTemplate(""); column.setValueRegEx("\\b(\\S\\D{3,})\\b"); assertEquals("word", column.getValue("1234sdcvdfv hfkdf34 word 2134", adapter, tuple)); column.setValueRegEx("\\b(\\S\\D{3,})\\b"); assertEquals("слово", column.getValue("1234sdcvdfv hfkdf34 слово 2134", adapter, tuple)); }