use of org.apache.metron.enrichment.converter.EnrichmentValue 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.EnrichmentValue 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.EnrichmentValue 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.EnrichmentValue 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());
}
use of org.apache.metron.enrichment.converter.EnrichmentValue in project metron by apache.
the class HBaseEnrichmentConverterTest method testPut.
@Test
public void testPut() throws IOException {
HbaseConverter<EnrichmentKey, EnrichmentValue> converter = new EnrichmentConverter();
Put put = converter.toPut("cf", key, value);
LookupKV<EnrichmentKey, EnrichmentValue> converted = converter.fromPut(put, "cf");
Assert.assertEquals(results, converted);
}
Aggregations