Skip to content

Commit

Permalink
[CLEANUP] Use newer LoadSaveTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Tucker committed Jun 2, 2016
1 parent 3e72c0d commit 8719998
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Expand Up @@ -22,9 +22,7 @@

package org.pentaho.di.trans.steps.mappinginput;

import org.apache.commons.lang.builder.ToStringBuilder;
import static org.junit.Assert.fail;
import org.pentaho.di.core.row.ValueMetaInterface;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -33,11 +31,13 @@
import java.util.Map;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.junit.Before;
import org.junit.Test;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.plugins.PluginRegistry;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.trans.steps.loadsave.LoadSaveTester;
import org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator;
import org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator;
Expand All @@ -50,7 +50,7 @@
*/
public class MappingInputMetaCloningTest {

LoadSaveTester loadSaveTester;
LoadSaveTester<MappingInputMeta> loadSaveTester;

@Test
public void clonesCorrectly() throws Exception {
Expand All @@ -70,7 +70,8 @@ public void clonesCorrectly() throws Exception {
+ "%s\n"
+ "\tCloned object:\n"
+ "%s";
fail( String.format( template, ToStringBuilder.reflectionToString( meta ), ToStringBuilder.reflectionToString( clone ) ) );
fail( String.format( template, ToStringBuilder.reflectionToString( meta ),
ToStringBuilder.reflectionToString( clone ) ) );
}
}

Expand All @@ -79,7 +80,8 @@ public void setUp() throws Exception {
KettleEnvironment.init();
PluginRegistry.init( true );
List<String> attributes =
Arrays.asList( "selectingAndSortingUnspecifiedFields", "fieldName", "fieldType", "fieldLength", "fieldPrecision" );
Arrays.asList( "selectingAndSortingUnspecifiedFields", "fieldName", "fieldType", "fieldLength",
"fieldPrecision" );

Map<String, String> getterMap = new HashMap<String, String>() {
{
Expand All @@ -106,9 +108,11 @@ public void setUp() throws Exception {
attrValidatorMap.put( "fieldName", stringArrayLoadSaveValidator );

Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put( int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator( new NonZeroIntLoadSaveValidator( 6 ), 5 ) );
typeValidatorMap.put( int[].class.getCanonicalName(),
new PrimitiveIntArrayLoadSaveValidator( new NonZeroIntLoadSaveValidator( 6 ), 5 ) );

loadSaveTester = new LoadSaveTester( MappingInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap );
loadSaveTester = new LoadSaveTester<MappingInputMeta>( MappingInputMeta.class, attributes, getterMap,
setterMap, attrValidatorMap, typeValidatorMap );
}

@Test
Expand Down
Expand Up @@ -51,13 +51,12 @@ public void loadSaveTest() throws KettleException {
fieldLoadSaveValidatorTypeMap.put( NormaliserField[].class.getCanonicalName(),
new ArrayLoadSaveValidator<NormaliserField>( new NormaliserFieldLoadSaveValidator( testField ), 50 ) );

LoadSaveTester tester =
new LoadSaveTester( NormaliserMeta.class, attributes, new HashMap<String, String>(),
LoadSaveTester<NormaliserMeta> tester =
new LoadSaveTester<NormaliserMeta>( NormaliserMeta.class, attributes, new HashMap<String, String>(),
new HashMap<String, String>(), new HashMap<String, FieldLoadSaveValidator<?>>(),
fieldLoadSaveValidatorTypeMap );

tester.testRepoRoundTrip();
tester.testXmlRoundTrip();
tester.testSerialization();
}

public static class NormaliserFieldLoadSaveValidator implements FieldLoadSaveValidator<NormaliserField> {
Expand Down

0 comments on commit 8719998

Please sign in to comment.