### Question:
ScriptValuesMod extends BaseTransform<ScriptValuesMetaMod, ScriptValuesModData> implements ITransform<ScriptValuesMetaMod, ScriptValuesModData> { public boolean init() { if ( super.init() ) { jsScripts = meta.getJSScripts(); for ( int j = 0; j < jsScripts.length; j++ ) { switch ( jsScripts[ j ].getScriptType() ) { case ScriptValuesScript.TRANSFORM_SCRIPT: strTransformScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.START_SCRIPT: strStartScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.END_SCRIPT: strEndScript = jsScripts[ j ].getScript(); break; default: break; } } return true; } return false; } ScriptValuesMod(TransformMeta transformMeta, ScriptValuesMetaMod meta, ScriptValuesModData data, int copyNr, PipelineMeta pipelineMeta,
                         Pipeline pipeline ); Object getValueFromJScript( Object result, int i ); IRowMeta getOutputRowMeta(); boolean processRow(); boolean init(); void dispose(); static final int SKIP_PIPELINE; static final int ABORT_PIPELINE; static final int ERROR_PIPELINE; static final int CONTINUE_PIPELINE; public Script script; }### Answer:
@Test @Ignore public void bigNumberAreNotTrimmedToInt() throws Exception { ScriptValuesMod transform = TransformMockUtil.getTransform( ScriptValuesMod.class, ScriptValuesMetaMod.class, ScriptValuesModData.class, "test" ); RowMeta input = new RowMeta(); input.addValueMeta( new ValueMetaBigNumber( "value_int" ) ); input.addValueMeta( new ValueMetaBigNumber( "value_double" ) ); transform.setInputRowMeta( input ); transform = spy( transform ); doReturn( new Object[] { BigDecimal.ONE, BigDecimal.ONE } ).when( transform ).getRow(); ScriptValuesMetaMod meta = new ScriptValuesMetaMod(); meta.allocate( 2 ); meta.setFieldname( new String[] { "value_int", "value_double" } ); meta.setType( new int[] { IValueMeta.TYPE_BIGNUMBER, IValueMeta.TYPE_BIGNUMBER } ); meta.setReplace( new boolean[] { true, true } ); meta.setJSScripts( new ScriptValuesScript[] { new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, "script", "value_int = 10.00;\nvalue_double = 10.50" ) } ); ScriptValuesModData data = new ScriptValuesModData(); transform.init(); Object[] expectedRow = { BigDecimal.TEN, new BigDecimal( "10.5" ) }; Object[] row = PipelineTestingUtil.execute( transform, 1, false ).get( 0 ); PipelineTestingUtil.assertResult( expectedRow, row ); }
@Test @Ignore public void variableIsSetInScopeOfTransform() throws Exception { ScriptValuesMod transform = TransformMockUtil.getTransform( ScriptValuesMod.class, ScriptValuesMetaMod.class, ScriptValuesModData.class, "test" ); RowMeta input = new RowMeta(); input.addValueMeta( new ValueMetaString( "str" ) ); transform.setInputRowMeta( input ); transform = spy( transform ); doReturn( new Object[] { "" } ).when( transform ).getRow(); ScriptValuesMetaMod meta = new ScriptValuesMetaMod(); meta.allocate( 1 ); meta.setFieldname( new String[] { "str" } ); meta.setType( new int[] { IValueMeta.TYPE_STRING } ); meta.setReplace( new boolean[] { true } ); meta.setJSScripts( new ScriptValuesScript[] { new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, "script", "setVariable('temp', 'pass', 'r');\nstr = getVariable('temp', 'fail');" ) } ); ScriptValuesModData data = new ScriptValuesModData(); transform.init(); Object[] expectedRow = { "pass" }; Object[] row = PipelineTestingUtil.execute( transform, 1, false ).get( 0 ); PipelineTestingUtil.assertResult( expectedRow, row ); }