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"));
}
Aggregations