Search in sources :

Example 1 with CacheKey

use of org.apache.metron.enrichment.bolt.CacheKey in project metron by apache.

the class GeoAdapterTest method testEnrichNonString.

@Test
public void testEnrichNonString() throws Exception {
    JSONObject actualMessage = geo.enrich(new CacheKey("dummy", 10L, null));
    Assert.assertEquals(new JSONObject(), actualMessage);
}
Also used : JSONObject(org.json.simple.JSONObject) CacheKey(org.apache.metron.enrichment.bolt.CacheKey) Test(org.junit.Test)

Example 2 with CacheKey

use of org.apache.metron.enrichment.bolt.CacheKey in project metron by apache.

the class HostFromJSONListAdapterTest method testEnrich.

@Test
public void testEnrich() throws Exception {
    HostFromJSONListAdapter hja = new HostFromJSONListAdapter(expectedKnownHostsString);
    JSONObject actualMessage = hja.enrich(new CacheKey("dummy", ip, null));
    Assert.assertNotNull(actualMessage);
    Assert.assertEquals(expectedMessage, actualMessage);
    actualMessage = hja.enrich(new CacheKey("dummy", ip1, null));
    JSONObject emptyJson = new JSONObject();
    Assert.assertEquals(emptyJson, actualMessage);
}
Also used : JSONObject(org.json.simple.JSONObject) CacheKey(org.apache.metron.enrichment.bolt.CacheKey) Test(org.junit.Test)

Example 3 with CacheKey

use of org.apache.metron.enrichment.bolt.CacheKey in project metron by apache.

the class SimpleHBaseAdapterTest method testMultiColumnFamiliesWrongCF.

@Test
public void testMultiColumnFamiliesWrongCF() 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));
    Assert.assertEquals(actualMessage, new JSONObject());
    actualMessage = sha.enrich(new CacheKey("ip_dst_addr", "10.0.2.4", broSc));
    Assert.assertNotNull(actualMessage);
    Assert.assertEquals(new JSONObject(new HashMap<String, Object>()), actualMessage);
}
Also used : JSONObject(org.json.simple.JSONObject) HashMap(java.util.HashMap) SensorEnrichmentConfig(org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig) CacheKey(org.apache.metron.enrichment.bolt.CacheKey) Test(org.junit.Test)

Example 4 with CacheKey

use of org.apache.metron.enrichment.bolt.CacheKey in project metron by apache.

the class SimpleHBaseAdapterTest method testEnrich.

@Test
public void testEnrich() 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));
    Assert.assertEquals(actualMessage, new JSONObject());
    actualMessage = sha.enrich(new CacheKey("ip_dst_addr", "10.0.2.3", broSc));
    Assert.assertNotNull(actualMessage);
    Assert.assertEquals(expectedMessage, actualMessage);
}
Also used : JSONObject(org.json.simple.JSONObject) SensorEnrichmentConfig(org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig) CacheKey(org.apache.metron.enrichment.bolt.CacheKey) Test(org.junit.Test)

Example 5 with CacheKey

use of org.apache.metron.enrichment.bolt.CacheKey in project metron by apache.

the class ThreatIntelAdapterTest method testEnrich.

@Test
public void testEnrich() throws Exception {
    ThreatIntelAdapter tia = new ThreatIntelAdapter();
    tia.lookup = lookup;
    SensorEnrichmentConfig broSc = JSONUtils.INSTANCE.load(sourceConfigStr, SensorEnrichmentConfig.class);
    JSONObject actualMessage = tia.enrich(new CacheKey("ip_dst_addr", "10.0.2.3", broSc));
    Assert.assertNotNull(actualMessage);
    Assert.assertEquals(expectedMessage, actualMessage);
}
Also used : JSONObject(org.json.simple.JSONObject) SensorEnrichmentConfig(org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig) CacheKey(org.apache.metron.enrichment.bolt.CacheKey) Test(org.junit.Test)

Aggregations

CacheKey (org.apache.metron.enrichment.bolt.CacheKey)13 JSONObject (org.json.simple.JSONObject)12 Test (org.junit.Test)11 SensorEnrichmentConfig (org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig)6 HashMap (java.util.HashMap)3 CacheStats (com.github.benmanes.caffeine.cache.stats.CacheStats)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 StellarAdapter (org.apache.metron.enrichment.adapters.stellar.StellarAdapter)1 JSONArray (org.json.simple.JSONArray)1 BeforeClass (org.junit.BeforeClass)1