Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
issue #12 : no data in step passed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Casters committed Jul 24, 2017
1 parent 87d3cd4 commit 66649eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/org/pentaho/di/dataset/spoon/DataSetHelper.java
Expand Up @@ -477,7 +477,6 @@ private boolean checkTestPresent(Spoon spoon, TransMeta transMeta) {
spoon.getLog().logBasic("Check test present...");

String testName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME );
spoon.getLog().logBasic("Check test present : "+testName);
if (!Const.isEmpty( testName )) {
return false;
}
Expand Down
25 changes: 19 additions & 6 deletions src/org/pentaho/di/dataset/util/DataSetConst.java
Expand Up @@ -40,6 +40,7 @@
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.core.row.value.ValueMetaString;
import org.pentaho.di.dataset.DataSet;
import org.pentaho.di.dataset.DataSetField;
import org.pentaho.di.dataset.DataSetGroup;
Expand Down Expand Up @@ -268,9 +269,16 @@ public static final int validateTransResultAgainstUnitTest(Trans trans, TransUni
int nrLocationErrors = 0;
RowCollection resultCollection = collectionMap.get( location.getStepname() );
if (resultCollection==null || resultCollection.getRows()==null || resultCollection.getRowMeta()==null) {
// error occurred upstairs, we don't have results
// error occurred somewhere, we don't have results, provide dummy values to avoid exceptions, flag error
//
continue;
resultCollection = new RowCollection();
resultCollection.setRowMeta(new RowMeta());
resultCollection.setRows(new ArrayList<Object[]>());

String comment = "WARNING: no test results found for step '" + location.getStepname() + "' : check disabled hops, input and so on.";
results.add(new UnitTestResult(
trans.getName(), unitTest.getName(), location.getDataSetName(), location.getStepname(),
false, comment));
}
RowMetaInterface resultRowMeta = resultCollection.getRowMeta();

Expand All @@ -279,11 +287,16 @@ public static final int validateTransResultAgainstUnitTest(Trans trans, TransUni
RowMetaInterface goldenRowMeta = new RowMeta();
for (TransUnitTestFieldMapping mapping : location.getFieldMappings()) {
ValueMetaInterface resultValueMeta = resultRowMeta.searchValueMeta(mapping.getStepFieldName());
ValueMetaInterface goldenValueMeta;
if (resultValueMeta!=null) {
ValueMetaInterface goldenValueMeta = resultValueMeta.clone();
goldenValueMeta.setName(mapping.getDataSetFieldName());
goldenRowMeta.addValueMeta(goldenValueMeta);
goldenValueMeta = resultValueMeta.clone();
} else {
// case where we have no results.
//
goldenValueMeta = new ValueMetaString(mapping.getStepFieldName());
}
goldenValueMeta.setName(mapping.getDataSetFieldName());
goldenRowMeta.addValueMeta(goldenValueMeta);
}

log.logBasic("Found "+resultCollection.getRows().size()+" results for comparrison in step '"+location.getStepname()+"', fields: "+resultRowMeta.toString());
Expand All @@ -299,7 +312,7 @@ public static final int validateTransResultAgainstUnitTest(Trans trans, TransUni
String comment = "Incorrect number of rows received from step, golden data set '" + location.getDataSetName() + "' has " + goldenRows.size() + " rows in it and we received "+resultRows.size();
results.add(new UnitTestResult(
trans.getName(), unitTest.getName(), location.getDataSetName(), location.getStepname(),
false, comment));
true, comment));
nrLocationErrors++;
}

Expand Down

0 comments on commit 66649eb

Please sign in to comment.