Search in sources :

Example 16 with ConfigHandler

use of org.apache.metron.common.configuration.enrichment.handler.ConfigHandler in project metron by apache.

the class StellarAdapterTest method test_default.

@Test
public void test_default() throws Exception {
    for (String c : DEFAULT_CONFIGS) {
        JSONObject message = getMessage();
        EnrichmentConfig enrichmentConfig = JSONUtils.INSTANCE.load(c, EnrichmentConfig.class);
        Assert.assertNotNull(enrichmentConfig.getEnrichmentConfigs().get("stellar"));
        ConfigHandler handler = enrichmentConfig.getEnrichmentConfigs().get("stellar");
        JSONObject enriched = enrich(message, "", handler);
        Assert.assertEquals("STELLAR_TEST", enriched.get("stmt1"));
        Assert.assertEquals("stellar_test", enriched.get("stmt2"));
        Assert.assertEquals("foo", enriched.get("stmt3"));
        Assert.assertEquals(3, enriched.size());
    }
}
Also used : JSONObject(org.json.simple.JSONObject) EnrichmentConfig(org.apache.metron.common.configuration.enrichment.EnrichmentConfig) ConfigHandler(org.apache.metron.common.configuration.enrichment.handler.ConfigHandler) StellarEnrichmentTest(org.apache.metron.common.configuration.StellarEnrichmentTest) Test(org.junit.Test)

Example 17 with ConfigHandler

use of org.apache.metron.common.configuration.enrichment.handler.ConfigHandler in project metron by apache.

the class StellarAdapterTest method test_grouped.

@Test
public void test_grouped() throws Exception {
    for (String c : GROUPED_CONFIGS) {
        JSONObject message = getMessage();
        EnrichmentConfig enrichmentConfig = JSONUtils.INSTANCE.load(c, EnrichmentConfig.class);
        Assert.assertNotNull(enrichmentConfig.getEnrichmentConfigs().get("stellar"));
        ConfigHandler handler = enrichmentConfig.getEnrichmentConfigs().get("stellar");
        {
            JSONObject enriched = enrich(message, "group1", handler);
            Assert.assertEquals("STELLAR_TEST", enriched.get("stmt1"));
            Assert.assertEquals("stellar_test", enriched.get("stmt2"));
            Assert.assertEquals(2, enriched.size());
        }
        {
            JSONObject enriched = enrich(message, "group2", handler);
            Assert.assertEquals("foo", enriched.get("stmt3"));
            Assert.assertEquals(1, enriched.size());
        }
    }
}
Also used : JSONObject(org.json.simple.JSONObject) EnrichmentConfig(org.apache.metron.common.configuration.enrichment.EnrichmentConfig) ConfigHandler(org.apache.metron.common.configuration.enrichment.handler.ConfigHandler) StellarEnrichmentTest(org.apache.metron.common.configuration.StellarEnrichmentTest) Test(org.junit.Test)

Aggregations

ConfigHandler (org.apache.metron.common.configuration.enrichment.handler.ConfigHandler)17 EnrichmentConfig (org.apache.metron.common.configuration.enrichment.EnrichmentConfig)13 JSONObject (org.json.simple.JSONObject)13 Test (org.junit.Test)12 Map (java.util.Map)6 ImmutableMap (com.google.common.collect.ImmutableMap)4 StellarEnrichmentTest (org.apache.metron.common.configuration.StellarEnrichmentTest)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)2 List (java.util.List)2 ArrayList (java.util.ArrayList)1 StellarProcessor (org.apache.metron.stellar.common.StellarProcessor)1 Context (org.apache.metron.stellar.dsl.Context)1 MapVariableResolver (org.apache.metron.stellar.dsl.MapVariableResolver)1 VariableResolver (org.apache.metron.stellar.dsl.VariableResolver)1