Search in sources :

Example 11 with CacheKey

use of org.apache.metron.enrichment.bolt.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));
    Assert.assertEquals(actualMessage, new JSONObject());
    actualMessage = sha.enrich(new CacheKey("ip_dst_addr", 10L, broSc));
    Assert.assertEquals(actualMessage, new JSONObject());
}
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 12 with CacheKey

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

the class ThreatIntelAdapterTest method testEnrichNonString.

@Test
public void testEnrichNonString() 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);
    actualMessage = tia.enrich(new CacheKey("ip_dst_addr", 10L, broSc));
    Assert.assertEquals(actualMessage, new JSONObject());
}
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 13 with CacheKey

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

the class ParallelEnricherTest method setup.

@BeforeClass
public static void setup() {
    ConcurrencyContext infrastructure = new ConcurrencyContext();
    infrastructure.initialize(5, 100, 10, null, null, false);
    stellarContext = new Context.Builder().build();
    StellarFunctions.initialize(stellarContext);
    StellarAdapter adapter = new StellarAdapter() {

        @Override
        public void logAccess(CacheKey value) {
            numAccesses.incrementAndGet();
        }
    }.ofType("ENRICHMENT");
    adapter.initializeAdapter(new HashMap<>());
    enrichmentsByType = ImmutableMap.of("stellar", adapter);
    enricher = new ParallelEnricher(enrichmentsByType, infrastructure, false);
}
Also used : StellarAdapter(org.apache.metron.enrichment.adapters.stellar.StellarAdapter) CacheKey(org.apache.metron.enrichment.bolt.CacheKey) BeforeClass(org.junit.BeforeClass)

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