use of org.apache.metron.enrichment.cache.CacheKey in project metron by apache.
the class HostFromPropertiesFileAdapterTest method testEnrich.
@Test
public void testEnrich() {
Map<String, JSONObject> mapKnownHosts = new HashMap<>();
JSONArray jsonArray = (JSONArray) JSONValue.parse(expectedKnownHostsString);
Iterator jsonArrayIterator = jsonArray.iterator();
while (jsonArrayIterator.hasNext()) {
JSONObject jsonObject = (JSONObject) jsonArrayIterator.next();
String host = (String) jsonObject.remove("ip");
mapKnownHosts.put(host, jsonObject);
}
HostFromPropertiesFileAdapter hfa = new HostFromPropertiesFileAdapter(mapKnownHosts);
JSONObject actualMessage = hfa.enrich(new CacheKey("dummy", ip, null));
assertNotNull(actualMessage);
assertEquals(expectedMessage, actualMessage);
actualMessage = hfa.enrich(new CacheKey("dummy", ip1, null));
JSONObject emptyJson = new JSONObject();
assertEquals(emptyJson, actualMessage);
}
use of org.apache.metron.enrichment.cache.CacheKey in project metron by apache.
the class HostFromJSONListAdapterTest method testEnrichNonString.
@Test
public void testEnrichNonString() {
HostFromJSONListAdapter hja = new HostFromJSONListAdapter(expectedKnownHostsString);
JSONObject actualMessage = hja.enrich(new CacheKey("dummy", ip, null));
assertNotNull(actualMessage);
assertEquals(expectedMessage, actualMessage);
actualMessage = hja.enrich(new CacheKey("dummy", 10L, null));
JSONObject emptyJson = new JSONObject();
assertEquals(emptyJson, actualMessage);
}
use of org.apache.metron.enrichment.cache.CacheKey in project metron by apache.
the class GeoAdapterTest method testEnrichNonString.
@Test
public void testEnrichNonString() {
JSONObject actualMessage = geo.enrich(new CacheKey("dummy", 10L, null));
assertEquals(new JSONObject(), actualMessage);
}
use of org.apache.metron.enrichment.cache.CacheKey in project metron by apache.
the class SimpleHBaseAdapterTest method testMultiColumnFamilies.
@Test
public void testMultiColumnFamilies() throws Exception {
SimpleHBaseAdapter sha = new SimpleHBaseAdapter();
sha.lookup = lookup;
SensorEnrichmentConfig broSc = JSONUtils.INSTANCE.load(sourceConfigWithCFStr, SensorEnrichmentConfig.class);
JSONObject actualMessage = sha.enrich(new CacheKey("test", "test", broSc));
assertEquals(actualMessage, new JSONObject());
actualMessage = sha.enrich(new CacheKey("ip_dst_addr", "10.0.2.4", broSc));
assertNotNull(actualMessage);
assertEquals(new JSONObject(ImmutableMap.of("cf1.key", "value")), actualMessage);
}
use of org.apache.metron.enrichment.cache.CacheKey in project metron by apache.
the class SimpleHBaseAdapterTest method testEnrichNonStringValue.
@Test
public void testEnrichNonStringValue() throws Exception {
SimpleHBaseAdapter sha = new SimpleHBaseAdapter();
sha.lookup = lookup;
SensorEnrichmentConfig broSc = JSONUtils.INSTANCE.load(sourceConfigStr, SensorEnrichmentConfig.class);
JSONObject actualMessage = sha.enrich(new CacheKey("test", "test", broSc));
assertEquals(actualMessage, new JSONObject());
actualMessage = sha.enrich(new CacheKey("ip_dst_addr", 10L, broSc));
assertEquals(actualMessage, new JSONObject());
}
Aggregations