
pl.allegro.tech.embeddedelasticsearch.InstanceSettings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of embedded-elasticsearch Show documentation
Show all versions of embedded-elasticsearch Show documentation
Tool that ease up creation of integration tests with Elasticsearch
package pl.allegro.tech.embeddedelasticsearch;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
class InstanceSettings {
private final ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory());
private final Map settings;
InstanceSettings() {
this(Collections.emptyMap());
}
InstanceSettings(Map settings) {
this.settings = Collections.unmodifiableMap(settings);
}
InstanceSettings withSetting(String key, Object value) {
Map extendedSettings = new HashMap<>();
extendedSettings.putAll(settings);
extendedSettings.put(key, value);
return new InstanceSettings(extendedSettings);
}
String toYaml() {
try {
return yamlObjectMapper.writeValueAsString(settings);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy