Search in sources :

Example 1 with SensorParserContext

use of org.apache.metron.rest.model.SensorParserContext in project metron by apache.

the class StellarServiceImplTest method applyTransformationsShouldProperlyTransformData.

@Test
public void applyTransformationsShouldProperlyTransformData() {
    SensorParserConfig sensorParserConfig = new SensorParserConfig();
    FieldTransformer fieldTransformater = new FieldTransformer();
    fieldTransformater.setOutput("url_host");
    fieldTransformater.setTransformation("STELLAR");
    fieldTransformater.setConfig(new LinkedHashMap<String, Object>() {

        {
            put("url_host", "TO_LOWER(URL_TO_HOST(url))");
        }
    });
    sensorParserConfig.setFieldTransformations(ImmutableList.of(fieldTransformater));
    SensorParserContext sensorParserContext = new SensorParserContext();
    sensorParserContext.setSensorParserConfig(sensorParserConfig);
    sensorParserContext.setSampleData(new HashMap<String, Object>() {

        {
            put("url", "https://caseystella.com/blog");
        }
    });
    Map<String, Object> results = stellarService.applyTransformations(sensorParserContext);
    assertEquals(2, results.size());
    assertEquals("https://caseystella.com/blog", results.get("url"));
    assertEquals("caseystella.com", results.get("url_host"));
}
Also used : SensorParserContext(org.apache.metron.rest.model.SensorParserContext) FieldTransformer(org.apache.metron.common.configuration.FieldTransformer) SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Test(org.junit.jupiter.api.Test)

Aggregations

FieldTransformer (org.apache.metron.common.configuration.FieldTransformer)1 SensorParserConfig (org.apache.metron.common.configuration.SensorParserConfig)1 SensorParserContext (org.apache.metron.rest.model.SensorParserContext)1 Test (org.junit.jupiter.api.Test)1