org.etlunit.ContextFeatureModule Maven / Gradle / Ivy
package org.etlunit;
import org.etlunit.context.VariableContext;
import org.etlunit.feature.AbstractFeature;
import org.etlunit.parser.ETLTestOperation;
import org.etlunit.parser.ETLTestValueObject;
import org.etlunit.parser.ETLTestVariable;
public class ContextFeatureModule extends AbstractFeature
{
private final class ContextListener extends NullClassListener
{
@Override
public void declare(ETLTestVariable var, VariableContext context)
{
// just pass on the declare to the context
context.declareVariable(var.getName());
// set the value
context.setValue(var.getName(), var.getValue());
}
// Provide a set variable method
@Override
public action_code process(ETLTestOperation op, ETLTestValueObject obj, VariableContext context, ExecutionContext econtext)
throws TestAssertionFailure, TestExecutionError, TestWarning
{
if (op.getOperationName().equals("set"))
{
context.declareAndSetValue(obj.query("variable").getValueAsString(), obj.query("value"));
return action_code.handled;
}
return action_code.defer;
}
}
private final ContextListener contextListener = new ContextListener();
@Override
public String getFeatureName()
{
return "context";
}
@Override
public ClassListener getListener()
{
return contextListener;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy