use of org.apache.metron.enrichment.writer.SimpleHbaseEnrichmentWriter in project metron by apache.
the class SimpleHBaseEnrichmentWriterTest method testConfigValidation_missing_key_columns.
@Test(expected = IllegalArgumentException.class)
public void testConfigValidation_missing_key_columns() {
final String sensorType = "dummy";
SimpleHbaseEnrichmentWriter writer = new SimpleHbaseEnrichmentWriter();
WriterConfiguration configuration = createConfig(1, new HashMap<String, Object>() {
{
put(SimpleHbaseEnrichmentWriter.Configurations.ENRICHMENT_TYPE.getKey(), ENRICHMENT_TYPE);
}
});
try {
writer.configure(sensorType, configuration);
} catch (IllegalArgumentException ex) {
Assert.assertEquals(String.format("%s must be provided", SimpleHbaseEnrichmentWriter.Configurations.KEY_COLUMNS.getKey()), ex.getMessage());
throw ex;
}
}
use of org.apache.metron.enrichment.writer.SimpleHbaseEnrichmentWriter in project metron by apache.
the class SimpleHBaseEnrichmentWriterTest method testBatchOneNormalPath.
@Test
public void testBatchOneNormalPath() throws Exception {
final String sensorType = "dummy";
SimpleHbaseEnrichmentWriter writer = new SimpleHbaseEnrichmentWriter();
WriterConfiguration configuration = createConfig(1, new HashMap<String, Object>(BASE_WRITER_CONFIG) {
{
put(SimpleHbaseEnrichmentWriter.Configurations.KEY_COLUMNS.getKey(), "ip");
}
});
writer.configure(sensorType, configuration);
writer.write(SENSOR_TYPE, configuration, null, new ArrayList<JSONObject>() {
{
add(new JSONObject(ImmutableMap.of("ip", "localhost", "user", "cstella", "foo", "bar")));
}
});
List<LookupKV<EnrichmentKey, EnrichmentValue>> values = getValues();
Assert.assertEquals(1, values.size());
Assert.assertEquals("localhost", values.get(0).getKey().indicator);
Assert.assertEquals("cstella", values.get(0).getValue().getMetadata().get("user"));
Assert.assertEquals("bar", values.get(0).getValue().getMetadata().get("foo"));
Assert.assertEquals(2, values.get(0).getValue().getMetadata().size());
}
use of org.apache.metron.enrichment.writer.SimpleHbaseEnrichmentWriter in project metron by apache.
the class SimpleHBaseEnrichmentWriterTest method testFilteredKey.
@Test
public void testFilteredKey() throws Exception {
final String sensorType = "dummy";
SimpleHbaseEnrichmentWriter writer = new SimpleHbaseEnrichmentWriter();
WriterConfiguration configuration = createConfig(1, new HashMap<String, Object>(BASE_WRITER_CONFIG) {
{
put(SimpleHbaseEnrichmentWriter.Configurations.KEY_COLUMNS.getKey(), "ip");
put(SimpleHbaseEnrichmentWriter.Configurations.VALUE_COLUMNS.getKey(), "user");
}
});
writer.configure(sensorType, configuration);
writer.write(SENSOR_TYPE, configuration, null, new ArrayList<JSONObject>() {
{
add(new JSONObject(ImmutableMap.of("ip", "localhost", "user", "cstella", "foo", "bar")));
}
});
List<LookupKV<EnrichmentKey, EnrichmentValue>> values = getValues();
Assert.assertEquals(1, values.size());
Assert.assertEquals("localhost", values.get(0).getKey().indicator);
Assert.assertEquals("cstella", values.get(0).getValue().getMetadata().get("user"));
Assert.assertNull(values.get(0).getValue().getMetadata().get("foo"));
Assert.assertEquals(1, values.get(0).getValue().getMetadata().size());
}
use of org.apache.metron.enrichment.writer.SimpleHbaseEnrichmentWriter in project metron by apache.
the class SimpleHBaseEnrichmentWriterTest method testConfigValidation_missing_enrichment_type.
@Test(expected = IllegalArgumentException.class)
public void testConfigValidation_missing_enrichment_type() {
final String sensorType = "dummy";
SimpleHbaseEnrichmentWriter writer = new SimpleHbaseEnrichmentWriter();
WriterConfiguration configuration = createConfig(1, new HashMap<String, Object>() {
{
put(SimpleHbaseEnrichmentWriter.Configurations.KEY_COLUMNS.getKey(), "ip");
}
});
try {
writer.configure(sensorType, configuration);
} catch (IllegalArgumentException ex) {
Assert.assertEquals(String.format("%s must be provided", SimpleHbaseEnrichmentWriter.Configurations.ENRICHMENT_TYPE.getKey()), ex.getMessage());
throw ex;
}
}
Aggregations