use of com.nextdoor.bender.operation.substitution.SubstitutionSpec in project bender by Nextdoor.
the class GelfOperationFactoryTest method foo.
@Test
public void foo() {
GelfOperationConfig config = new GelfOperationConfig();
config.setSrcHostField("foo_host");
config.setSrcShortMessageField("foo_short_message");
config.setSrcFileField("filename");
GelfOperationFactory factory = new GelfOperationFactory();
factory.setConf(config);
GelfOperation op = factory.newInstance();
ArrayList<SubstitutionSpec> actual = op.getSubSpecs();
ArrayList<SubstitutionSpec> expected = new ArrayList<SubstitutionSpec>();
expected.add(new SubstitutionSpec("host", "foo_host", Interpreter.FIELD));
expected.add(new SubstitutionSpec("file", "filename", Interpreter.FIELD));
expected.add(new SubstitutionSpec("short_message", "foo_short_message", Interpreter.FIELD));
expected.add(new SubstitutionSpec("version", "1.1", Interpreter.STATIC));
Collections.sort(expected, Comparator.comparingInt(Object::hashCode));
Collections.sort(actual, Comparator.comparingInt(Object::hashCode));
assertEquals(expected, actual);
}
use of com.nextdoor.bender.operation.substitution.SubstitutionSpec in project bender by Nextdoor.
the class GelfOperationFactory method setConf.
@Override
public void setConf(AbstractConfig config) {
this.config = (GelfOperationConfig) config;
ArrayList<SubstitutionSpec> subSpecs = new ArrayList<SubstitutionSpec>();
this.subSpecs = subSpecs;
subSpecs.add(new SubstitutionSpec("version", "1.1", Interpreter.STATIC));
if (this.config.getSrcHostField() != null) {
subSpecs.add(new SubstitutionSpec("host", this.config.getSrcHostField(), Interpreter.FIELD));
}
if (this.config.getSrcShortMessageField() != null) {
subSpecs.add(new SubstitutionSpec("short_message", this.config.getSrcShortMessageField(), Interpreter.FIELD));
}
if (this.config.getSrcFullMessageField() != null) {
subSpecs.add(new SubstitutionSpec("full_message", this.config.getSrcFullMessageField(), Interpreter.FIELD));
}
if (this.config.getSrcTimestampField() != null) {
subSpecs.add(new SubstitutionSpec("timestamp", this.config.getSrcTimestampField(), Interpreter.FIELD));
}
if (this.config.getSrcLevelField() != null) {
subSpecs.add(new SubstitutionSpec("level", this.config.getSrcLevelField(), Interpreter.FIELD));
}
if (this.config.getSrcFacilityField() != null) {
subSpecs.add(new SubstitutionSpec("facility", this.config.getSrcFacilityField(), Interpreter.FIELD));
}
if (this.config.getSrcLineNumberField() != null) {
subSpecs.add(new SubstitutionSpec("line", this.config.getSrcLineNumberField(), Interpreter.FIELD));
}
if (this.config.getSrcFileField() != null) {
subSpecs.add(new SubstitutionSpec("file", this.config.getSrcFileField(), Interpreter.FIELD));
}
}
Aggregations