-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
DenormaliserMetaInjectionIT.java
91 lines (76 loc) · 3.17 KB
/
DenormaliserMetaInjectionIT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*! ******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2017 by Pentaho : http://www.pentaho.com
*
*******************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package org.pentaho.di.trans.steps.denormaliser;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.plugins.Plugin;
import org.pentaho.di.core.plugins.PluginInterface;
import org.pentaho.di.core.plugins.PluginRegistry;
import org.pentaho.di.core.plugins.PluginTypeInterface;
import org.pentaho.di.core.plugins.StepPluginType;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.StepMetaInterface;
import org.pentaho.di.trans.steps.metainject.MetaInject;
import org.pentaho.di.trans.steps.metainject.MetaInjectMeta;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DenormaliserMetaInjectionIT {
private static final String EXPECTED_VALUE = "1";
private TransMeta transMeta;
private Trans trans;
@BeforeClass
public static void initKettle() throws Exception {
KettleEnvironment.init( false );
Map<Class<?>, String> classMap = new HashMap<>();
classMap.put( StepMetaInterface.class, "org.pentaho.di.trans.steps.metainject.MetaInjectMeta" );
List<String> libraries = new ArrayList<>();
PluginInterface plugin =
new Plugin( new String[] { "MetaInject" }, StepPluginType.class, StepMetaInterface.class, "Flow",
"MetaInjectMeta", null, null, false, false, classMap, libraries, null, null );
PluginRegistry.getInstance().registerPlugin( StepPluginType.class, plugin );
}
@Before
public void setUp() throws Exception {
transMeta = new TransMeta( "src/it/resources/org/pentaho/di/trans/steps/denormaliser/pdi-11947.ktr" );
transMeta.setTransformationType( TransMeta.TransformationType.Normal );
trans = new Trans( transMeta );
}
@Test
public void testAddedFieldsAvailableOutsideInjectedTransformation() throws Exception {
runTransformation( trans );
String actualValue = trans.getVariable( "X_FIELD_VALUE" );
assertEquals( EXPECTED_VALUE, actualValue );
}
private static void runTransformation( Trans trans ) throws Exception {
trans.prepareExecution( null );
trans.startThreads();
trans.waitUntilFinished();
assertEquals( 0, trans.getErrors() );
}
}