CSVExtractor extends CSVConverter implements Extractor { @Override public void initialize(Map<String, Object> config) { super.initialize(config); if(config.containsKey(INDICATOR_COLUMN_KEY)) { indicatorColumn = columnMap.get(config.get(INDICATOR_COLUMN_KEY).toString()); } if(config.containsKey(TYPE_KEY)) { type = config.get(TYPE_KEY).toString(); } else if(config.containsKey(TYPE_COLUMN_KEY)) { typeColumnIndex = columnMap.get(config.get(TYPE_COLUMN_KEY).toString()); } if(config.containsKey(LOOKUP_CONVERTER)) { converter = LookupConverters.getConverter((String) config.get(LOOKUP_CONVERTER)); } }  int getTypeColumnIndex(); String getType(); int getIndicatorColumn(); LookupConverter getConverter(); @Override Iterable<LookupKV> extract(String line); @Override void initialize(Map<String, Object> config); static final String INDICATOR_COLUMN_KEY; static final String TYPE_COLUMN_KEY; static final String TYPE_KEY; static final String LOOKUP_CONVERTER; }
@Test public void testInitialize() throws Exception { CSVExtractor ex = new CSVExtractor(); ExtractorHandler handler = ExtractorHandler.load(testCSVConfig); ex.initialize(handler.getConfig()); assertEquals(0, (int)ex.getColumnMap().get("host") ); assertEquals(2, (int)ex.getColumnMap().get("meta") ); assertEquals(0, ex.getTypeColumnIndex() ); assertEquals(0, ex.getIndicatorColumn()); assertEquals("threat", ex.getType() ); assertEquals(',', ex.getParser().getSeparator()); }