use of org.apache.metron.common.configuration.EnrichmentConfigurations in project metron by apache.
the class GlobalConfigServiceImpl method get.
@Override
public Map<String, Object> get() throws RestException {
Map<String, Object> globalConfig;
try {
EnrichmentConfigurations configs = cache.get(EnrichmentConfigurations.class);
globalConfig = configs.getGlobalConfig(false);
} catch (Exception e) {
throw new RestException(e.getMessage(), e);
}
return globalConfig;
}
use of org.apache.metron.common.configuration.EnrichmentConfigurations in project metron by apache.
the class SensorEnrichmentConfigServiceImplTest method getAllShouldProperlyReturnSensorEnrichmentConfigs.
@Test
public void getAllShouldProperlyReturnSensorEnrichmentConfigs() throws Exception {
final SensorEnrichmentConfig sensorEnrichmentConfig = getTestSensorEnrichmentConfig();
EnrichmentConfigurations configs = new EnrichmentConfigurations() {
@Override
public Map<String, Object> getConfigurations() {
return ImmutableMap.of(EnrichmentConfigurations.getKey("bro"), sensorEnrichmentConfig);
}
};
when(cache.get(eq(EnrichmentConfigurations.class))).thenReturn(configs);
assertEquals(new HashMap() {
{
put("bro", sensorEnrichmentConfig);
}
}, sensorEnrichmentConfigService.getAll());
}
use of org.apache.metron.common.configuration.EnrichmentConfigurations in project metron by apache.
the class GlobalConfigServiceImplTest method getShouldProperlyReturnGlobalConfig.
@Test
public void getShouldProperlyReturnGlobalConfig() throws Exception {
final String config = "{\"k\":\"v\"}";
final Map<String, Object> configMap = new HashMap<String, Object>() {
{
put("k", "v");
}
};
EnrichmentConfigurations configs = new EnrichmentConfigurations() {
@Override
public Map<String, Object> getConfigurations() {
return ImmutableMap.of(ConfigurationType.GLOBAL.getTypeName(), configMap);
}
};
when(cache.get(eq(EnrichmentConfigurations.class))).thenReturn(configs);
assertEquals(configMap, globalConfigService.get());
}
use of org.apache.metron.common.configuration.EnrichmentConfigurations in project metron by apache.
the class SensorEnrichmentConfigServiceImplTest method findOneShouldProperlyReturnSensorEnrichmentConfig.
@Test
public void findOneShouldProperlyReturnSensorEnrichmentConfig() throws Exception {
final SensorEnrichmentConfig sensorEnrichmentConfig = getTestSensorEnrichmentConfig();
EnrichmentConfigurations configs = new EnrichmentConfigurations() {
@Override
public Map<String, Object> getConfigurations() {
return ImmutableMap.of(EnrichmentConfigurations.getKey("bro"), sensorEnrichmentConfig);
}
};
when(cache.get(eq(EnrichmentConfigurations.class))).thenReturn(configs);
// We only have bro, so we should expect it to be returned
assertEquals(getTestSensorEnrichmentConfig(), sensorEnrichmentConfigService.findOne("bro"));
// and blah should be a miss.
assertNull(sensorEnrichmentConfigService.findOne("blah"));
}
use of org.apache.metron.common.configuration.EnrichmentConfigurations in project metron by apache.
the class SensorEnrichmentConfigServiceImplTest method getAllTypesShouldProperlyReturnTypes.
@Test
public void getAllTypesShouldProperlyReturnTypes() throws Exception {
EnrichmentConfigurations configs = new EnrichmentConfigurations() {
@Override
public Map<String, Object> getConfigurations() {
return ImmutableMap.of(EnrichmentConfigurations.getKey("bro"), new HashMap<>(), EnrichmentConfigurations.getKey("squid"), new HashMap<>());
}
};
when(cache.get(eq(EnrichmentConfigurations.class))).thenReturn(configs);
assertEquals(new ArrayList() {
{
add("bro");
add("squid");
}
}, sensorEnrichmentConfigService.getAllTypes());
}
Aggregations