@Test public void testGetColumnConstant() throws Exception { final CsvImportColumn column = mockery.mock(CsvImportColumn.class, "column"); final CsvValueAdapter adapter = mockery.mock(CsvValueAdapter.class, "adapter"); final String[] line = new String[] { "val1", "val2" }; final CsvImportTupleImpl tuple = new CsvImportTupleImpl("file", 1, line); mockery.checking(new Expectations() {{ allowing(column).getColumnIndex(); will(returnValue(-1)); allowing(column).getValue(null, adapter, tuple); will(returnValue("const")); }}); assertEquals(tuple.getColumnValue(column, adapter), "const"); mockery.assertIsSatisfied(); }
@Override public Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter) { final int colIndex = column.getColumnIndex(); String rawValue = null; if (colIndex > -1 && line != null && colIndex < line.length) { rawValue = line[colIndex]; } if (rawValue != null && column.getGroupCount(rawValue) > 1) { return column.getValues(rawValue, valueAdapter, this); } return column.getValue(rawValue, valueAdapter, this); }
CsvImportTupleImpl implements CsvImportTuple { @Override public Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter) { final int colIndex = column.getColumnIndex(); String rawValue = null; if (colIndex > -1 && line != null && colIndex < line.length) { rawValue = line[colIndex]; } if (rawValue != null && column.getGroupCount(rawValue) > 1) { return column.getValues(rawValue, valueAdapter, this); } return column.getValue(rawValue, valueAdapter, this); } }
CsvImportTupleImpl implements CsvImportTuple { @Override public Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter) { final int colIndex = column.getColumnIndex(); String rawValue = null; if (colIndex > -1 && line != null && colIndex < line.length) { rawValue = line[colIndex]; } if (rawValue != null && column.getGroupCount(rawValue) > 1) { return column.getValues(rawValue, valueAdapter, this); } return column.getValue(rawValue, valueAdapter, this); } CsvImportTupleImpl(final String filename, final long lineNumber, final String[] line); }
CsvImportTupleImpl implements CsvImportTuple { @Override public Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter) { final int colIndex = column.getColumnIndex(); String rawValue = null; if (colIndex > -1 && line != null && colIndex < line.length) { rawValue = line[colIndex]; } if (rawValue != null && column.getGroupCount(rawValue) > 1) { return column.getValues(rawValue, valueAdapter, this); } return column.getValue(rawValue, valueAdapter, this); } CsvImportTupleImpl(final String filename, final long lineNumber, final String[] line); @Override String getSourceId(); @Override String[] getData(); @Override Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter); @Override List<CsvImportTuple> getSubTuples(final CsvImportDescriptor importDescriptor, final CsvImportColumn column, final CsvValueAdapter valueAdapter); @Override String toString(); }
CsvImportTupleImpl implements CsvImportTuple { @Override public Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter) { final int colIndex = column.getColumnIndex(); String rawValue = null; if (colIndex > -1 && line != null && colIndex < line.length) { rawValue = line[colIndex]; } if (rawValue != null && column.getGroupCount(rawValue) > 1) { return column.getValues(rawValue, valueAdapter, this); } return column.getValue(rawValue, valueAdapter, this); } CsvImportTupleImpl(final String filename, final long lineNumber, final String[] line); @Override String getSourceId(); @Override String[] getData(); @Override Object getColumnValue(final CsvImportColumn column, final CsvValueAdapter valueAdapter); @Override List<CsvImportTuple> getSubTuples(final CsvImportDescriptor importDescriptor, final CsvImportColumn column, final CsvValueAdapter valueAdapter); @Override String toString();  }