org.etlunit.feature.debug.DebugFeatureModule Maven / Gradle / Ivy
package org.etlunit.feature.debug;
import org.etlunit.*;
import org.etlunit.context.VariableContext;
import org.etlunit.feature.AbstractFeature;
import org.etlunit.feature.FeatureModule;
import org.etlunit.parser.ETLTestOperation;
import org.etlunit.parser.ETLTestValueObject;
@FeatureModule
public class DebugFeatureModule extends AbstractFeature
{
@Override
public String getFeatureName()
{
return "debug";
}
@Override
public ClassListener getListener()
{
return new NullClassListener()
{
@Override
public action_code process(ETLTestOperation op, ETLTestValueObject obj, final VariableContext context, ExecutionContext econtext)
throws TestAssertionFailure, TestExecutionError, TestWarning
{
String name = op.getOperationName();
if (name.equals("error"))
{
ETLTestValueObject errorId = obj.query("error-id");
if (errorId != null)
{
throw new TestExecutionError(obj.getValueAsMap().get("message").getValueAsString(),
errorId.getValueAsString());
}
else
{
throw new TestExecutionError(obj.getValueAsMap().get("message").getValueAsString());
}
}
else if (name.equals("die"))
{
throw new RuntimeException("Blech");
}
else if (name.equals("fail"))
{
ETLTestValueObject errorId = obj.query("failure-id");
if (errorId != null)
{
throw new TestAssertionFailure(op.getOperands().getValueAsMap().get("message").getValueAsString(),
errorId.getValueAsString());
}
else
{
throw new TestAssertionFailure(op.getOperands().getValueAsMap().get("message").getValueAsString());
}
}
else if (name.equals("warn"))
{
ETLTestValueObject errorId = obj.query("warning-id");
if (errorId != null)
{
throw new TestWarning(op.getOperands().getValueAsMap().get("message").getValueAsString(),
errorId.getValueAsString());
}
else
{
throw new TestWarning(op.getOperands().getValueAsMap().get("message").getValueAsString());
}
}
return action_code.defer;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy