Search in sources :

Example 76 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class TransMetaTest method testTransWithOneStepIsConsideredUsed.

@Test
public void testTransWithOneStepIsConsideredUsed() throws Exception {
    TransMeta transMeta = new TransMeta(getClass().getResource("one-step-trans.ktr").getPath());
    assertEquals(1, transMeta.getUsedSteps().size());
    Repository rep = mock(Repository.class);
    ProgressMonitorListener monitor = mock(ProgressMonitorListener.class);
    List<CheckResultInterface> remarks = new ArrayList<>();
    IMetaStore metaStore = mock(IMetaStore.class);
    transMeta.checkSteps(remarks, false, monitor, new Variables(), rep, metaStore);
    assertEquals(4, remarks.size());
    for (CheckResultInterface remark : remarks) {
        assertEquals(CheckResultInterface.TYPE_RESULT_OK, remark.getType());
    }
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 77 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class TransMetaConverterTest method testResolveStepMetaResources.

@Test
public void testResolveStepMetaResources() throws KettleException, MetaStoreException {
    Variables variables = new Variables();
    TransMeta transMeta = spy(new TransMeta());
    transMeta.setParentVariableSpace(variables);
    doReturn(transMeta).when(transMeta).realClone(false);
    TestMetaResolvableResource testMetaResolvableResource = spy(new TestMetaResolvableResource());
    TestMetaResolvableResource testMetaResolvableResourceTwo = spy(new TestMetaResolvableResource());
    StepMeta testMeta = new StepMeta("TestMeta", testMetaResolvableResource);
    StepMeta testMetaTwo = new StepMeta("TestMeta2", testMetaResolvableResourceTwo);
    transMeta.addStep(testMeta);
    transMeta.addStep(testMetaTwo);
    transMeta.addTransHop(new TransHopMeta(testMeta, testMetaTwo));
    TransMetaConverter.convert(transMeta);
    verify(testMetaResolvableResource).resolve();
    verify(testMetaResolvableResourceTwo).resolve();
}
Also used : Variables(org.pentaho.di.core.variables.Variables) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 78 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class MergeRowsMetaCheckTest method testCheckInputRowsEmptyAndNonEmpty.

@Test
public void testCheckInputRowsEmptyAndNonEmpty() throws KettleStepException {
    when(transMeta.getPrevStepFields(REFERENCE_STEP_NAME)).thenReturn(generateRowMetaEmpty());
    when(transMeta.getPrevStepFields(COMPARISON_STEP_NAME)).thenReturn(generateRowMeta10Strings());
    meta.check(remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null);
    assertNotNull(remarks);
    assertTrue(remarks.size() >= 2);
    assertEquals(remarks.get(1).getType(), CheckResultInterface.TYPE_RESULT_ERROR);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Test(org.junit.Test)

Example 79 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class MergeRowsMetaCheckTest method testCheckInputRowsBothNonEmpty.

@Test
public void testCheckInputRowsBothNonEmpty() throws KettleStepException {
    when(transMeta.getPrevStepFields(REFERENCE_STEP_NAME)).thenReturn(generateRowMeta10Strings());
    when(transMeta.getPrevStepFields(COMPARISON_STEP_NAME)).thenReturn(generateRowMeta10Strings());
    meta.check(remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null);
    assertNotNull(remarks);
    assertTrue(remarks.size() >= 2);
    assertEquals(remarks.get(1).getType(), CheckResultInterface.TYPE_RESULT_OK);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Test(org.junit.Test)

Example 80 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class DetectLastRowMetaTest method testGetFields.

@Test
public void testGetFields() throws KettleStepException {
    DetectLastRowMeta meta = new DetectLastRowMeta();
    meta.setDefault();
    meta.setResultFieldName("The Result");
    RowMeta rowMeta = new RowMeta();
    meta.getFields(rowMeta, "this step", null, null, new Variables(), null, null);
    assertEquals(1, rowMeta.size());
    assertEquals("The Result", rowMeta.getValueMeta(0).getName());
    assertEquals(ValueMetaInterface.TYPE_BOOLEAN, rowMeta.getValueMeta(0).getType());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) RowMeta(org.pentaho.di.core.row.RowMeta) Test(org.junit.Test)

Aggregations

Variables (org.pentaho.di.core.variables.Variables)119 Test (org.junit.Test)67 TransMeta (org.pentaho.di.trans.TransMeta)31 ArrayList (java.util.ArrayList)25 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)20 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)20 StepMeta (org.pentaho.di.trans.step.StepMeta)18 RowMeta (org.pentaho.di.core.row.RowMeta)17 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)16 VariableSpace (org.pentaho.di.core.variables.VariableSpace)14 Repository (org.pentaho.di.repository.Repository)12 TableView (org.pentaho.di.ui.core.widget.TableView)10 FormAttachment (org.eclipse.swt.layout.FormAttachment)9 FormData (org.eclipse.swt.layout.FormData)9 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)9 Label (org.eclipse.swt.widgets.Label)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)7