use of org.apache.metron.enrichment.converter.EnrichmentKey in project metron by apache.
the class SimpleHBaseEnrichmentFunctionsTest method setup.
@Before
public void setup() throws Exception {
final MockHTable hbaseTable = (MockHTable) MockHBaseTableProvider.addToCache(hbaseTableName, cf);
EnrichmentHelper.INSTANCE.load(hbaseTable, cf, new ArrayList<LookupKV<EnrichmentKey, EnrichmentValue>>() {
{
for (int i = 0; i < 5; ++i) {
add(new LookupKV<>(new EnrichmentKey(ENRICHMENT_TYPE, "indicator" + i), new EnrichmentValue(ImmutableMap.of("key" + i, "value" + i))));
}
}
});
context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> ImmutableMap.of(SimpleHBaseEnrichmentFunctions.TABLE_PROVIDER_TYPE_CONF, MockHBaseTableProvider.class.getName())).build();
}
use of org.apache.metron.enrichment.converter.EnrichmentKey in project metron by apache.
the class HostnameHandler method extract.
@Override
public Iterable<LookupKV> extract(final Hostname type, Map<String, Object> config) throws IOException {
StringObjectPropertyType value = type.getHostnameValue();
String typeStr = getType();
if (config != null) {
Object o = config.get(TYPE_CONFIG);
if (o != null) {
typeStr = o.toString();
}
}
List<LookupKV> ret = new ArrayList<>();
for (String token : StixExtractor.split(value)) {
final String indicatorType = typeStr;
LookupKV results = new LookupKV(new EnrichmentKey(indicatorType, token), new EnrichmentValue(new HashMap<String, Object>() {
{
put("source-type", "STIX");
put("indicator-type", indicatorType);
put("source", type.toXMLString());
}
}));
ret.add(results);
}
return ret;
}
use of org.apache.metron.enrichment.converter.EnrichmentKey in project metron by apache.
the class TransformFilterExtractorDecoratorTest method filters_indicators.
@Test
public void filters_indicators() throws Exception {
EnrichmentKey lookupKey = new EnrichmentKey("testenrichment", "");
EnrichmentValue lookupValue = new EnrichmentValue(new HashMap<String, Object>() {
{
put("foo", "val1");
put("bar", "");
put("baz", "val3");
}
});
LookupKV lkv = new LookupKV<>(lookupKey, lookupValue);
List<LookupKV> extractedLkvs = new ArrayList<>();
extractedLkvs.add(lkv);
Mockito.when(extractor.extract("val1,,val3")).thenReturn(extractedLkvs);
Iterable<LookupKV> extracted = decorator.extract("val1,,val3");
Assert.assertThat(extracted, CoreMatchers.equalTo(new ArrayList<>()));
}
use of org.apache.metron.enrichment.converter.EnrichmentKey in project metron by apache.
the class HBaseEnrichmentConverterTest method testResult.
@Test
public void testResult() throws IOException {
HbaseConverter<EnrichmentKey, EnrichmentValue> converter = new EnrichmentConverter();
Result r = converter.toResult("cf", key, value);
LookupKV<EnrichmentKey, EnrichmentValue> converted = converter.fromResult(r, "cf");
Assert.assertEquals(results, converted);
}
use of org.apache.metron.enrichment.converter.EnrichmentKey in project metron by apache.
the class HBaseEnrichmentConverterTest method testGet.
@Test
public void testGet() throws Exception {
HbaseConverter<EnrichmentKey, EnrichmentValue> converter = new EnrichmentConverter();
Get get = converter.toGet("cf", key);
Assert.assertArrayEquals(key.toBytes(), get.getRow());
}
Aggregations