use of org.pentaho.actionsequence.dom.actions.ResultSetCompareAction in project pentaho-platform by pentaho.
the class ResultSetCompareComponent method validateAction.
@Override
protected boolean validateAction() {
boolean actionValidated = true;
ResultSetCompareAction compareAction = null;
// get report connection setting
if (getActionDefinition() instanceof ResultSetCompareAction) {
compareAction = (ResultSetCompareAction) getActionDefinition();
if (compareAction.getResultSet1() == ActionInputConstant.NULL_INPUT) {
actionValidated = false;
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0001_INPUT_RS1_UNDEFINED"));
}
if (actionValidated && (compareAction.getResultSet2() == ActionInputConstant.NULL_INPUT)) {
actionValidated = false;
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0002_INPUT_RS2_UNDEFINED"));
}
if (actionValidated && (compareAction.getCompareColumnNum() == ActionInputConstant.NULL_INPUT)) {
actionValidated = false;
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0003_COLUMN_UNDEFINED"));
}
} else {
actionValidated = false;
error(Messages.getInstance().getErrorString("ComponentBase.ERROR_0001_UNKNOWN_ACTION_TYPE", // $NON-NLS-1$
getActionDefinition().getElement().asXML()));
}
return actionValidated;
}
use of org.pentaho.actionsequence.dom.actions.ResultSetCompareAction in project pentaho-platform by pentaho.
the class ResultSetCompareComponent method executeAction.
@Override
protected boolean executeAction() throws Throwable {
ResultSetCompareAction compareAction = (ResultSetCompareAction) getActionDefinition();
Object obj1 = compareAction.getResultSet1().getValue();
if (!(obj1 instanceof IPentahoResultSet)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0004_INPUT_RS1_NOT_RS"));
return false;
}
Object obj2 = compareAction.getResultSet2().getValue();
if (!(obj2 instanceof IPentahoResultSet)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0005_INPUT_RS2_NOT_RS"));
return false;
}
IPentahoResultSet rs1 = (IPentahoResultSet) compareAction.getResultSet1().getValue();
IPentahoResultSet rs2 = (IPentahoResultSet) compareAction.getResultSet2().getValue();
String tempOutputMismatches = compareAction.getOutputMismatches().getStringValue();
boolean outputMismatches = false;
if ((tempOutputMismatches != null) && tempOutputMismatches.trim().toLowerCase().equals("true")) {
// $NON-NLS-1$
outputMismatches = true;
}
boolean stopOnError = false;
String tempStopOnError = compareAction.getStopOnError().getStringValue();
if ((tempStopOnError != null) && tempStopOnError.trim().toLowerCase().equals("true")) {
// $NON-NLS-1$
stopOnError = true;
}
int compareCol = Integer.parseInt(compareAction.getCompareColumnNum().getStringValue());
return compareEquals(rs1, rs2, compareCol, outputMismatches, stopOnError);
}
use of org.pentaho.actionsequence.dom.actions.ResultSetCompareAction in project pentaho-platform by pentaho.
the class ResultSetCompareComponentTest method validationSuccessful.
@Test
public void validationSuccessful() {
ResultSetCompareComponent rscc = createResultSetCompareComponent();
IPentahoResultSet rs = Mockito.mock(IPentahoResultSet.class);
ResultSetCompareAction resultSetCompareAction = createResultSetCompareAction(rs, rs, 0, false, true);
rscc.setActionDefinition(resultSetCompareAction);
int actualValidateResult = rscc.validate();
assertEquals(IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK, actualValidateResult);
}
use of org.pentaho.actionsequence.dom.actions.ResultSetCompareAction in project pentaho-platform by pentaho.
the class ResultSetCompareComponentTest method createResultSetCompareAction.
private static ResultSetCompareAction createResultSetCompareAction(IPentahoResultSet resultSet1, IPentahoResultSet resultSet2, Integer compareColumnNum, boolean outputMismatches, boolean stopOnError) {
ResultSetCompareAction resultSetCompareAction = mock(ResultSetCompareAction.class);
IActionInput resultSetInput1 = ActionInputConstant.NULL_INPUT;
if (resultSet1 != null) {
resultSetInput1 = mock(IActionInput.class);
when(resultSetInput1.getValue()).thenReturn(resultSet1);
}
when(resultSetCompareAction.getResultSet1()).thenReturn(resultSetInput1);
IActionInput resultSetInput2 = ActionInputConstant.NULL_INPUT;
if (resultSet2 != null) {
resultSetInput2 = mock(IActionInput.class);
when(resultSetInput2.getValue()).thenReturn(resultSet2);
}
when(resultSetCompareAction.getResultSet2()).thenReturn(resultSetInput2);
IActionInput compareColumnNumInput = ActionInputConstant.NULL_INPUT;
if (compareColumnNum != null) {
compareColumnNumInput = mock(IActionInput.class);
when(compareColumnNumInput.getStringValue()).thenReturn(String.valueOf(compareColumnNum));
}
when(resultSetCompareAction.getCompareColumnNum()).thenReturn(compareColumnNumInput);
IActionInput outputMismatchesInput = mock(IActionInput.class);
when(outputMismatchesInput.getStringValue()).thenReturn(String.valueOf(outputMismatches));
when(resultSetCompareAction.getOutputMismatches()).thenReturn(outputMismatchesInput);
IActionInput stopOnErrorInput = mock(IActionInput.class);
when(stopOnErrorInput.getStringValue()).thenReturn(String.valueOf(stopOnError));
when(resultSetCompareAction.getStopOnError()).thenReturn(stopOnErrorInput);
return resultSetCompareAction;
}
use of org.pentaho.actionsequence.dom.actions.ResultSetCompareAction in project pentaho-platform by pentaho.
the class ResultSetCompareComponentTest method callValidationWithResultSets.
private static int callValidationWithResultSets(IPentahoResultSet resultSet1, IPentahoResultSet resultSet2) {
ResultSetCompareComponent rscc = createResultSetCompareComponent();
ResultSetCompareAction resultSetCompareAction = createResultSetCompareAction(resultSet1, resultSet2, 0, false, true);
rscc.setActionDefinition(resultSetCompareAction);
return rscc.validate();
}
Aggregations