use of org.apache.metron.common.configuration.enrichment.EnrichmentConfig in project metron by apache.
the class StellarEnrichmentConfigTest method testSplitter_mixed.
@Test
public void testSplitter_mixed() throws IOException {
JSONObject message = getMessage();
for (String c : Iterables.concat(MIXED_CONFIGS, ImmutableList.of(tempVarStellarConfig_list))) {
EnrichmentConfig enrichmentConfig = JSONUtils.INSTANCE.load(c, EnrichmentConfig.class);
Assert.assertNotNull(enrichmentConfig.getEnrichmentConfigs().get("stellar"));
ConfigHandler handler = enrichmentConfig.getEnrichmentConfigs().get("stellar");
List<JSONObject> splits = Configs.STELLAR.splitByFields(message, null, x -> null, handler);
Assert.assertEquals(3, splits.size());
{
Map<String, Object> split = (Map<String, Object>) splits.get(0).get("group1");
Assert.assertEquals(2, split.size());
Assert.assertEquals("stellar_test", split.get("source.type"));
Assert.assertNull(split.get("stmt1"));
}
{
Map<String, Object> split = (Map<String, Object>) splits.get(1).get("group2");
Assert.assertEquals(1, split.size());
Assert.assertEquals("foo", split.get("string"));
}
{
Map<String, Object> split = (Map<String, Object>) splits.get(2).get("");
Assert.assertEquals(1, split.size());
Assert.assertEquals("stellar_test", split.get("source.type"));
}
}
}
use of org.apache.metron.common.configuration.enrichment.EnrichmentConfig in project metron by apache.
the class StellarEnrichmentConfigTest method testGetSubgroups_mixed.
@Test
public void testGetSubgroups_mixed() throws IOException {
for (String c : MIXED_CONFIGS) {
EnrichmentConfig enrichmentConfig = JSONUtils.INSTANCE.load(c, EnrichmentConfig.class);
Assert.assertNotNull(enrichmentConfig.getEnrichmentConfigs().get("stellar"));
ConfigHandler handler = enrichmentConfig.getEnrichmentConfigs().get("stellar");
List<String> subgroups = Configs.STELLAR.getSubgroups(handler);
Assert.assertEquals("group1", subgroups.get(0));
Assert.assertEquals("group2", subgroups.get(1));
Assert.assertEquals("", subgroups.get(2));
Assert.assertEquals(3, subgroups.size());
}
}
use of org.apache.metron.common.configuration.enrichment.EnrichmentConfig 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());
}
}
use of org.apache.metron.common.configuration.enrichment.EnrichmentConfig 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());
}
}
}
Aggregations