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

Commit

Permalink
Fixing, implementing issues #6, #10, #22, #23, #24
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasters committed Nov 7, 2018
1 parent 860819a commit 039ac40
Show file tree
Hide file tree
Showing 17 changed files with 660 additions and 502 deletions.
295 changes: 202 additions & 93 deletions src/main/java/org/pentaho/di/dataset/TransUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.dataset.spoon.xtpoint.RowCollection;
import org.pentaho.di.dataset.util.DataSetConst;
import org.pentaho.di.dataset.util.FactoriesHierarchy;
import org.pentaho.metastore.persist.MetaStoreAttribute;
import org.pentaho.metastore.persist.MetaStoreElementType;
Expand Down Expand Up @@ -75,6 +76,9 @@ public class TransUnitTest {
@MetaStoreAttribute( key = "persist_filename")
protected String filename;

@MetaStoreAttribute
protected String basePath;

@MetaStoreAttribute( key = "database_replacements" )
protected List<TransUnitTestDatabaseReplacement> databaseReplacements;

Expand All @@ -88,6 +92,7 @@ public TransUnitTest() {
type = TestType.NONE;
databaseReplacements = new ArrayList<TransUnitTestDatabaseReplacement>();
variableValues = new ArrayList<>();
basePath = DataSetConst.VARIABLE_UNIT_TESTS_BASE_PATH;
}

public TransUnitTest( String name, String description,
Expand Down Expand Up @@ -127,72 +132,8 @@ public boolean equals( Object obj ) {
public int hashCode() {
return name.hashCode();
}


public String getName() {
return name;
}

public void setName( String name ) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription( String description ) {
this.description = description;
}

public List<TransUnitTestSetLocation> getInputDataSets() {
return inputDataSets;
}

public void setInputDataSets( List<TransUnitTestSetLocation> inputDataSets ) {
this.inputDataSets = inputDataSets;
}

public String getTransObjectId() {
return transObjectId;
}

public void setTransObjectId( String transObjectId ) {
this.transObjectId = transObjectId;
}

public String getTransRepositoryPath() {
return transRepositoryPath;
}

public void setTransRepositoryPath( String transRepositoryPath ) {
this.transRepositoryPath = transRepositoryPath;
}

public String getTransFilename() {
return transFilename;
}

public void setTransFilename( String transFilename ) {
this.transFilename = transFilename;
}

public List<TransUnitTestSetLocation> getGoldenDataSets() {
return goldenDataSets;
}

public void setGoldenDataSets( List<TransUnitTestSetLocation> goldenDataSets ) {
this.goldenDataSets = goldenDataSets;
}

public List<TransUnitTestTweak> getTweaks() {
return tweaks;
}

public void setTweaks(List<TransUnitTestTweak> tweaks) {
this.tweaks = tweaks;
}

public TransUnitTestSetLocation findGoldenLocation(String stepName) {
for (TransUnitTestSetLocation location : goldenDataSets) {
if (stepName.equalsIgnoreCase( location.getStepname() )) {
Expand All @@ -201,7 +142,7 @@ public TransUnitTestSetLocation findGoldenLocation(String stepName) {
}
return null;
}

public TransUnitTestSetLocation findInputLocation(String stepName) {
for (TransUnitTestSetLocation location : inputDataSets) {
if (stepName.equalsIgnoreCase( location.getStepname() )) {
Expand All @@ -210,15 +151,15 @@ public TransUnitTestSetLocation findInputLocation(String stepName) {
}
return null;
}

/**
* Retrieve the golden data set for the specified location
*
* @param log the logging channel to log to
* @param hierarchy The factories to load sets with
* @param location the location where we want to check against golden rows
* @return The golden data set
*
*
* @throws KettleException
*/
public DataSet getGoldenDataSet(LogChannelInterface log, FactoriesHierarchy hierarchy, TransUnitTestSetLocation location) throws KettleException {
Expand All @@ -232,7 +173,7 @@ public DataSet getGoldenDataSet(LogChannelInterface log, FactoriesHierarchy hier
if (goldenDataSetName==null) {
throw new KettleException("Unable to find golden data set for step '"+stepName+"'");
}

DataSet goldenDataSet = hierarchy.getSetFactory().loadElement( goldenDataSetName );
if (goldenDataSet==null) {
throw new KettleException("Unable to find golden data set '"+goldenDataSetName+"' for step '"+stepName+"'");
Expand All @@ -245,7 +186,7 @@ public DataSet getGoldenDataSet(LogChannelInterface log, FactoriesHierarchy hier
}
}

/** Find the first tweak for a certain step
/** Find the first tweak for a certain step
* @param stepname the name of the step on which a tweak is put
* @return the first tweak for a certain step or null if nothing was found
*/
Expand All @@ -258,27 +199,216 @@ public TransUnitTestTweak findTweak(String stepname) {
return null;
}

/**
* Remove all input and golden data sets on the step with the provided name
* @param stepname the name of the step for which we need to clear out all input and golden data sets
*/
public void removeInputAndGoldenDataSets(String stepname) {

for (Iterator<TransUnitTestSetLocation> iterator = inputDataSets.iterator() ; iterator.hasNext() ; ) {
TransUnitTestSetLocation inputLocation = iterator.next();
if (inputLocation.getStepname().equalsIgnoreCase(stepname)) {
iterator.remove();
}
}

for (Iterator<TransUnitTestSetLocation> iterator = goldenDataSets.iterator() ; iterator.hasNext() ; ) {
TransUnitTestSetLocation goldenLocation = iterator.next();
if (goldenLocation.getStepname().equalsIgnoreCase(stepname)) {
iterator.remove();
}
}
}

/**
* Gets name
*
* @return value of name
*/
public String getName() {
return name;
}

/**
* @param name The name to set
*/
public void setName( String name ) {
this.name = name;
}

/**
* Gets description
*
* @return value of description
*/
public String getDescription() {
return description;
}

/**
* @param description The description to set
*/
public void setDescription( String description ) {
this.description = description;
}

/**
* Gets transObjectId
*
* @return value of transObjectId
*/
public String getTransObjectId() {
return transObjectId;
}

/**
* @param transObjectId The transObjectId to set
*/
public void setTransObjectId( String transObjectId ) {
this.transObjectId = transObjectId;
}

/**
* Gets transRepositoryPath
*
* @return value of transRepositoryPath
*/
public String getTransRepositoryPath() {
return transRepositoryPath;
}

/**
* @param transRepositoryPath The transRepositoryPath to set
*/
public void setTransRepositoryPath( String transRepositoryPath ) {
this.transRepositoryPath = transRepositoryPath;
}

/**
* Gets transFilename
*
* @return value of transFilename
*/
public String getTransFilename() {
return transFilename;
}

/**
* @param transFilename The transFilename to set
*/
public void setTransFilename( String transFilename ) {
this.transFilename = transFilename;
}

/**
* Gets inputDataSets
*
* @return value of inputDataSets
*/
public List<TransUnitTestSetLocation> getInputDataSets() {
return inputDataSets;
}

/**
* @param inputDataSets The inputDataSets to set
*/
public void setInputDataSets( List<TransUnitTestSetLocation> inputDataSets ) {
this.inputDataSets = inputDataSets;
}

/**
* Gets goldenDataSets
*
* @return value of goldenDataSets
*/
public List<TransUnitTestSetLocation> getGoldenDataSets() {
return goldenDataSets;
}

/**
* @param goldenDataSets The goldenDataSets to set
*/
public void setGoldenDataSets( List<TransUnitTestSetLocation> goldenDataSets ) {
this.goldenDataSets = goldenDataSets;
}

/**
* Gets tweaks
*
* @return value of tweaks
*/
public List<TransUnitTestTweak> getTweaks() {
return tweaks;
}

/**
* @param tweaks The tweaks to set
*/
public void setTweaks( List<TransUnitTestTweak> tweaks ) {
this.tweaks = tweaks;
}

/**
* Gets type
*
* @return value of type
*/
public TestType getType() {
return type;
}

public void setType(TestType type) {
/**
* @param type The type to set
*/
public void setType( TestType type ) {
this.type = type;
}

/**
* Gets filename
*
* @return value of filename
*/
public String getFilename() {
return filename;
}

public void setFilename(String filename) {
/**
* @param filename The filename to set
*/
public void setFilename( String filename ) {
this.filename = filename;
}

/**
* Gets basePath
*
* @return value of basePath
*/
public String getBasePath() {
return basePath;
}

/**
* @param basePath The basePath to set
*/
public void setBasePath( String basePath ) {
this.basePath = basePath;
}

/**
* Gets databaseReplacements
*
* @return value of databaseReplacements
*/
public List<TransUnitTestDatabaseReplacement> getDatabaseReplacements() {
return databaseReplacements;
}

public void setDatabaseReplacements(List<TransUnitTestDatabaseReplacement> databaseReplacements) {
/**
* @param databaseReplacements The databaseReplacements to set
*/
public void setDatabaseReplacements( List<TransUnitTestDatabaseReplacement> databaseReplacements ) {
this.databaseReplacements = databaseReplacements;
}

Expand All @@ -297,25 +427,4 @@ public List<VariableValue> getVariableValues() {
public void setVariableValues( List<VariableValue> variableValues ) {
this.variableValues = variableValues;
}

/**
* Remove all input and golden data sets on the step with the provided name
* @param stepname the name of the step for which we need to clear out all input and golden data sets
*/
public void removeInputAndGoldenDataSets(String stepname) {

for (Iterator<TransUnitTestSetLocation> iterator = inputDataSets.iterator() ; iterator.hasNext() ; ) {
TransUnitTestSetLocation inputLocation = iterator.next();
if (inputLocation.getStepname().equalsIgnoreCase(stepname)) {
iterator.remove();
}
}

for (Iterator<TransUnitTestSetLocation> iterator = goldenDataSets.iterator() ; iterator.hasNext() ; ) {
TransUnitTestSetLocation goldenLocation = iterator.next();
if (goldenLocation.getStepname().equalsIgnoreCase(stepname)) {
iterator.remove();
}
}
}
}
Loading

0 comments on commit 039ac40

Please sign in to comment.