CsvToKeyValueMapper extends Mapper<LongWritable,Text,ImmutableBytesWritable,
        KeyValue> { @VisibleForTesting static ImportPreUpsertKeyValueProcessor loadPreUpsertProcessor(Configuration conf) { Class<? extends ImportPreUpsertKeyValueProcessor> processorClass = null; try { processorClass = conf.getClass( UPSERT_HOOK_CLASS_CONFKEY, DefaultImportPreUpsertKeyValueProcessor.class, ImportPreUpsertKeyValueProcessor.class); } catch (Exception e) { throw new IllegalStateException("Couldn't load upsert hook class", e); } return ReflectionUtils.newInstance(processorClass, conf); }   static final String UPSERT_HOOK_CLASS_CONFKEY; static final String FIELD_DELIMITER_CONFKEY; static final String QUOTE_CHAR_CONFKEY; static final String ESCAPE_CHAR_CONFKEY; static final String ARRAY_DELIMITER_CONFKEY; static final String TABLE_NAME_CONFKEY; static final String INDEX_TABLE_NAME_CONFKEY; static final String COLUMN_INFO_CONFKEY; static final String IGNORE_INVALID_ROW_CONFKEY; }
@Test public void testLoadPreUpdateProcessor() { Configuration conf = new Configuration(); conf.setClass(CsvToKeyValueMapper.UPSERT_HOOK_CLASS_CONFKEY, MockUpsertProcessor.class, ImportPreUpsertKeyValueProcessor.class); ImportPreUpsertKeyValueProcessor processor = CsvToKeyValueMapper.loadPreUpsertProcessor(conf); assertEquals(MockUpsertProcessor.class, processor.getClass()); }
@Test public void testLoadPreUpdateProcessor_NotConfigured() { Configuration conf = new Configuration(); ImportPreUpsertKeyValueProcessor processor = CsvToKeyValueMapper.loadPreUpsertProcessor(conf); assertEquals(CsvToKeyValueMapper.DefaultImportPreUpsertKeyValueProcessor.class, processor.getClass()); }
@Test(expected=IllegalStateException.class) public void testLoadPreUpdateProcessor_ClassNotFound() { Configuration conf = new Configuration(); conf.set(CsvToKeyValueMapper.UPSERT_HOOK_CLASS_CONFKEY, "MyUndefinedClass"); CsvToKeyValueMapper.loadPreUpsertProcessor(conf); }