use of org.apache.metron.enrichment.converter.EnrichmentConverter in project metron by apache.
the class SimpleEnrichmentFlatFileLoaderIntegrationTest method testLocalLineByLine_gz.
@Test
public void testLocalLineByLine_gz() throws Exception {
String[] argv = { "-c cf", "-t enrichment", "-e " + lineByLineExtractorConfigFile.getPath(), "-i " + multilineGzFile.getPath(), "-p 2", "-b 128", "-q" };
SimpleEnrichmentFlatFileLoader.main(config, argv);
EnrichmentConverter converter = new EnrichmentConverter();
ResultScanner scanner = testTable.getScanner(Bytes.toBytes(cf));
List<LookupKV<EnrichmentKey, EnrichmentValue>> results = new ArrayList<>();
for (Result r : scanner) {
results.add(converter.fromResult(r, cf));
testTable.delete(new Delete(r.getRow()));
}
Assert.assertEquals(NUM_LINES, results.size());
Assert.assertTrue(results.get(0).getKey().indicator.startsWith("google"));
Assert.assertEquals(results.get(0).getKey().type, "enrichment");
Assert.assertEquals(results.get(0).getValue().getMetadata().size(), 2);
Assert.assertTrue(results.get(0).getValue().getMetadata().get("meta").toString().startsWith("foo"));
Assert.assertTrue(results.get(0).getValue().getMetadata().get("host").toString().startsWith("google"));
}
use of org.apache.metron.enrichment.converter.EnrichmentConverter in project metron by apache.
the class TaxiiIntegrationTest method getIndicators.
private static Set<String> getIndicators(String indicatorType, Iterable<Put> puts, String cf) throws IOException {
EnrichmentConverter converter = new EnrichmentConverter();
Set<String> ret = new HashSet<>();
for (Put p : puts) {
LookupKV<EnrichmentKey, EnrichmentValue> kv = converter.fromPut(p, cf);
if (kv.getKey().type.equals(indicatorType)) {
ret.add(kv.getKey().indicator);
}
}
return ret;
}
Aggregations