Skip to content

Commit

Permalink
[TEST] - Additional load/save tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbatchelor committed May 25, 2016
1 parent 317c14c commit de8e927
Show file tree
Hide file tree
Showing 20 changed files with 773 additions and 90 deletions.
Expand Up @@ -109,6 +109,7 @@ public void setKeyFields( String[] keyFields ) {
this.keyFields = keyFields; this.keyFields = keyFields;
} }


@Override
public boolean excludeFromRowLayoutVerification() { public boolean excludeFromRowLayoutVerification() {
return true; return true;
} }
Expand All @@ -117,6 +118,7 @@ public MultiMergeJoinMeta() {
super(); // allocate BaseStepMeta super(); // allocate BaseStepMeta
} }


@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
readData( stepnode ); readData( stepnode );
} }
Expand All @@ -125,6 +127,7 @@ public void allocateKeys( int nrKeys ) {
keyFields = new String[nrKeys]; keyFields = new String[nrKeys];
} }


@Override
public Object clone() { public Object clone() {
MultiMergeJoinMeta retval = (MultiMergeJoinMeta) super.clone(); MultiMergeJoinMeta retval = (MultiMergeJoinMeta) super.clone();
int nrKeys = keyFields.length; int nrKeys = keyFields.length;
Expand All @@ -136,6 +139,7 @@ public Object clone() {
return retval; return retval;
} }


@Override
public String getXML() { public String getXML() {
StringBuilder retval = new StringBuilder(); StringBuilder retval = new StringBuilder();


Expand Down Expand Up @@ -193,11 +197,13 @@ private void readData( Node stepnode ) throws KettleXMLException {
} }
} }


@Override
public void setDefault() { public void setDefault() {
joinType = join_types[0]; joinType = join_types[0];
allocateKeys( 0 ); allocateKeys( 0 );
} }


@Override
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases )
throws KettleException { throws KettleException {
try { try {
Expand All @@ -217,14 +223,18 @@ public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, Lis
String stepName = rep.getStepAttributeString( id_step, "step" + i ); String stepName = rep.getStepAttributeString( id_step, "step" + i );
getStepIOMeta().addStream( getStepIOMeta().addStream(
new Stream( StreamType.INFO, null, BaseMessages.getString( PKG, "MultiMergeJoin.InfoStream.Description" ), new Stream( StreamType.INFO, null, BaseMessages.getString( PKG, "MultiMergeJoin.InfoStream.Description" ),
StreamIcon.INFO, null ) ); StreamIcon.INFO, stepName ) );
inputSteps[i] = stepName; inputSteps[i] = stepName;
} }
List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams(); // This next bit is completely unnecessary if you just pass the step name into

// the constructor above. That sets the subject to the step name in one pass
for ( int i = 0; i < infoStreams.size(); i++ ) { // instead of a second one.
infoStreams.get( i ).setSubject( rep.getStepAttributeString( id_step, "step" + i ) ); // MB - 5/2016
} //
// List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
// for ( int i = 0; i < infoStreams.size(); i++ ) {
// infoStreams.get( i ).setSubject( rep.getStepAttributeString( id_step, "step" + i ) );
// }


joinType = rep.getStepAttributeString( id_step, "join_type" ); joinType = rep.getStepAttributeString( id_step, "join_type" );
} catch ( Exception e ) { } catch ( Exception e ) {
Expand All @@ -240,26 +250,35 @@ public void searchInfoAndTargetSteps( List<StepMeta> steps ) {
} }
} }


@Override
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step )
throws KettleException { throws KettleException {
try { try {
for ( int i = 0; i < keyFields.length; i++ ) { for ( int i = 0; i < keyFields.length; i++ ) {
rep.saveStepAttribute( id_transformation, id_step, i, "keys", keyFields[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "keys", keyFields[i] );
} }


List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams(); String[] inputStepsNames = inputSteps != null ? inputSteps : ArrayUtils.EMPTY_STRING_ARRAY;

rep.saveStepAttribute( id_transformation, id_step, "number_input", inputStepsNames.length );
rep.saveStepAttribute( id_transformation, id_step, "number_input", infoStreams.size() ); for ( int i = 0; i < inputStepsNames.length; i++ ) {
for ( int i = 0; i < infoStreams.size(); i++ ) { rep.saveStepAttribute( id_transformation, id_step, "step" + i, inputStepsNames[ i ] );
rep.saveStepAttribute( id_transformation, id_step, "step" + i, infoStreams.get( i ).getStepname() );
} }
// The following was the old way of persisting this step to the repository. This was inconsistent with
// how getXML works, and also fails the load/save tester
// List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
// rep.saveStepAttribute( id_transformation, id_step, "number_input", infoStreams.size() );
// for ( int i = 0; i < infoStreams.size(); i++ ) {
// rep.saveStepAttribute( id_transformation, id_step, "step" + i, infoStreams.get( i ).getStepname() );
// }
// inputSteps[i]
rep.saveStepAttribute( id_transformation, id_step, "join_type", getJoinType() ); rep.saveStepAttribute( id_transformation, id_step, "join_type", getJoinType() );
} catch ( Exception e ) { } catch ( Exception e ) {
throw new KettleException( BaseMessages.getString( PKG, "MultiMergeJoinMeta.Exception.UnableToSaveStepInfo" ) throw new KettleException( BaseMessages.getString( PKG, "MultiMergeJoinMeta.Exception.UnableToSaveStepInfo" )
+ id_step, e ); + id_step, e );
} }
} }


@Override
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository, String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ) { IMetaStore metaStore ) {
Expand All @@ -273,6 +292,7 @@ public void check( List<CheckResultInterface> remarks, TransMeta transMeta, Step
remarks.add( cr ); remarks.add( cr );
} }


@Override
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
// We don't have any input fields here in "r" as they are all info fields. // We don't have any input fields here in "r" as they are all info fields.
Expand All @@ -292,15 +312,18 @@ public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info,
return; return;
} }


@Override
public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr, public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ) { Trans trans ) {
return new MultiMergeJoin( stepMeta, stepDataInterface, cnr, tr, trans ); return new MultiMergeJoin( stepMeta, stepDataInterface, cnr, tr, trans );
} }


@Override
public StepDataInterface getStepData() { public StepDataInterface getStepData() {
return new MultiMergeJoinData(); return new MultiMergeJoinData();
} }


@Override
public void resetStepIoMeta() { public void resetStepIoMeta() {
// Don't reset! // Don't reset!
} }
Expand Down
Expand Up @@ -2,7 +2,7 @@
* *
* Pentaho Data Integration * Pentaho Data Integration
* *
* Copyright (C) 2002-2013 by Pentaho : http://www.pentaho.com * Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com
* *
******************************************************************************* *******************************************************************************
* *
Expand Down Expand Up @@ -81,7 +81,16 @@ public PGPDecryptStreamMeta() {
super(); // allocate BaseStepMeta super(); // allocate BaseStepMeta
} }


public void setGPGPLocation( String gpglocation ) { /**
* @deprecated typo
* @param gpglocation
*/
@Deprecated
public void setGPGPLocation( String value ) {
this.setGPGLocation( value );
}

public void setGPGLocation( String gpglocation ) {
this.gpglocation = gpglocation; this.gpglocation = gpglocation;
} }


Expand Down Expand Up @@ -144,11 +153,22 @@ public String getResultFieldName() {
/** /**
* @param resultfieldname * @param resultfieldname
* The resultfieldname to set. * The resultfieldname to set.
* @deprecated typo
*/ */
public void setResultfieldname( String resultfieldname ) { @Deprecated
this.resultfieldname = resultfieldname; public void setResultfieldname( String value ) {
this.setResultFieldName( value );
} }


/**
*
* @param resultfieldname
* The resultFieldName to set
*
*/
public void setResultFieldName( String resultfieldname ) {
this.resultfieldname = resultfieldname;
}
/** /**
* @return Returns the passhrase. * @return Returns the passhrase.
*/ */
Expand All @@ -164,23 +184,27 @@ public void setPassphrase( String passhrase ) {
this.passhrase = passhrase; this.passhrase = passhrase;
} }


@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
readData( stepnode, databases ); readData( stepnode, databases );
} }


@Override
public Object clone() { public Object clone() {
PGPDecryptStreamMeta retval = (PGPDecryptStreamMeta) super.clone(); PGPDecryptStreamMeta retval = (PGPDecryptStreamMeta) super.clone();


return retval; return retval;
} }


@Override
public void setDefault() { public void setDefault() {
resultfieldname = "result"; resultfieldname = "result";
streamfield = null; streamfield = null;
passhrase = null; passhrase = null;
gpglocation = null; gpglocation = null;
} }


@Override
public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
// Output fields (String) // Output fields (String)
Expand All @@ -192,6 +216,7 @@ public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterf


} }


@Override
public String getXML() { public String getXML() {
StringBuilder retval = new StringBuilder(); StringBuilder retval = new StringBuilder();
retval.append( " " + XMLHandler.addTagValue( "gpglocation", gpglocation ) ); retval.append( " " + XMLHandler.addTagValue( "gpglocation", gpglocation ) );
Expand All @@ -218,6 +243,7 @@ private void readData( Node stepnode, List<? extends SharedObjectInterface> data
} }
} }


@Override
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {
try { try {
gpglocation = rep.getStepAttributeString( id_step, "gpglocation" ); gpglocation = rep.getStepAttributeString( id_step, "gpglocation" );
Expand All @@ -233,6 +259,7 @@ public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, Lis
} }
} }


@Override
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException {
try { try {
rep.saveStepAttribute( id_transformation, id_step, "gpglocation", gpglocation ); rep.saveStepAttribute( id_transformation, id_step, "gpglocation", gpglocation );
Expand All @@ -249,6 +276,7 @@ public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transform
} }
} }


@Override
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ) { Repository repository, IMetaStore metaStore ) {
Expand Down Expand Up @@ -307,15 +335,18 @@ public void check( List<CheckResultInterface> remarks, TransMeta transMeta, Step


} }


@Override
public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ) { TransMeta transMeta, Trans trans ) {
return new PGPDecryptStream( stepMeta, stepDataInterface, cnr, transMeta, trans ); return new PGPDecryptStream( stepMeta, stepDataInterface, cnr, transMeta, trans );
} }


@Override
public StepDataInterface getStepData() { public StepDataInterface getStepData() {
return new PGPDecryptStreamData(); return new PGPDecryptStreamData();
} }


@Override
public boolean supportsErrorHandling() { public boolean supportsErrorHandling() {
return true; return true;
} }
Expand Down
Expand Up @@ -80,8 +80,16 @@ public PGPEncryptStreamMeta() {
super(); // allocate BaseStepMeta super(); // allocate BaseStepMeta
} }


public void setGPGPLocation( String gpglocation ) { /**
this.gpglocation = gpglocation; * @deprecated - typo
*/
@Deprecated
public void setGPGPLocation( String value ) {
this.setGPGLocation( value );
}

public void setGPGLocation( String value ) {
this.gpglocation = value;
} }


public String getGPGLocation() { public String getGPGLocation() {
Expand Down Expand Up @@ -140,12 +148,20 @@ public String getResultFieldName() {
return resultfieldname; return resultfieldname;
} }


/**
* @deprecated - typo
*/
@Deprecated
public void setResultfieldname( String value ) {
this.setResultFieldName( value );
}

/** /**
* @param resultfieldname * @param resultfieldname
* The resultfieldname to set. * The resultfieldname to set.
*/ */
public void setResultfieldname( String resultfieldname ) { public void setResultFieldName( String value ) {
this.resultfieldname = resultfieldname; this.resultfieldname = value;
} }


/** /**
Expand All @@ -163,16 +179,19 @@ public void setKeyName( String keyname ) {
this.keyname = keyname; this.keyname = keyname;
} }


@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
readData( stepnode, databases ); readData( stepnode, databases );
} }


@Override
public Object clone() { public Object clone() {
PGPEncryptStreamMeta retval = (PGPEncryptStreamMeta) super.clone(); PGPEncryptStreamMeta retval = (PGPEncryptStreamMeta) super.clone();


return retval; return retval;
} }


@Override
public void setDefault() { public void setDefault() {
resultfieldname = "result"; resultfieldname = "result";
streamfield = null; streamfield = null;
Expand All @@ -182,6 +201,7 @@ public void setDefault() {
keynameFieldName = null; keynameFieldName = null;
} }


@Override
public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
// Output fields (String) // Output fields (String)
Expand All @@ -193,6 +213,7 @@ public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterf


} }


@Override
public String getXML() { public String getXML() {
StringBuilder retval = new StringBuilder(); StringBuilder retval = new StringBuilder();
retval.append( " " + XMLHandler.addTagValue( "gpglocation", gpglocation ) ); retval.append( " " + XMLHandler.addTagValue( "gpglocation", gpglocation ) );
Expand All @@ -219,6 +240,7 @@ private void readData( Node stepnode, List<? extends SharedObjectInterface> data
} }
} }


@Override
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {
try { try {
gpglocation = rep.getStepAttributeString( id_step, "gpglocation" ); gpglocation = rep.getStepAttributeString( id_step, "gpglocation" );
Expand All @@ -233,6 +255,7 @@ public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, Lis
} }
} }


@Override
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException {
try { try {
rep.saveStepAttribute( id_transformation, id_step, "gpglocation", gpglocation ); rep.saveStepAttribute( id_transformation, id_step, "gpglocation", gpglocation );
Expand All @@ -248,6 +271,7 @@ public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transform
} }
} }


@Override
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ) { Repository repository, IMetaStore metaStore ) {
Expand Down Expand Up @@ -305,15 +329,18 @@ public void check( List<CheckResultInterface> remarks, TransMeta transMeta, Step


} }


@Override
public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ) { TransMeta transMeta, Trans trans ) {
return new PGPEncryptStream( stepMeta, stepDataInterface, cnr, transMeta, trans ); return new PGPEncryptStream( stepMeta, stepDataInterface, cnr, transMeta, trans );
} }


@Override
public StepDataInterface getStepData() { public StepDataInterface getStepData() {
return new PGPEncryptStreamData(); return new PGPEncryptStreamData();
} }


@Override
public boolean supportsErrorHandling() { public boolean supportsErrorHandling() {
return true; return true;
} }
Expand Down

0 comments on commit de8e927

Please sign in to comment.