Search in sources :

Example 26 with StepErrorMeta

use of org.pentaho.di.trans.step.StepErrorMeta in project pentaho-kettle by pentaho.

the class SpoonTest method testCopyPasteStepsErrorHandling.

/**
 * test two steps
 * @see http://jira.pentaho.com/browse/PDI-689
 *
 * @throws KettleException
 */
@Test
public void testCopyPasteStepsErrorHandling() throws KettleException {
    final TransMeta transMeta = new TransMeta();
    // for check copy both step and hop
    StepMeta sourceStep = new StepMeta("CsvInput", "Step1", new CsvInputMeta());
    StepMeta targetStep = new StepMeta("Dummy", "Dummy Step1", new DummyTransMeta());
    sourceStep.setSelected(true);
    targetStep.setSelected(true);
    transMeta.addStep(sourceStep);
    transMeta.addStep(targetStep);
    StepErrorMeta errorMeta = new StepErrorMeta(transMeta, sourceStep, targetStep);
    sourceStep.setStepErrorMeta(errorMeta);
    errorMeta.setSourceStep(sourceStep);
    errorMeta.setTargetStep(targetStep);
    final int stepsSizeBefore = transMeta.getSteps().size();
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            spoon.pasteXML(transMeta, (String) invocation.getArguments()[0], mock(Point.class));
            assertTrue("Steps was not copied", stepsSizeBefore < transMeta.getSteps().size());
            // selected copied step
            for (StepMeta s : transMeta.getSelectedSteps()) {
                if (s.getStepMetaInterface() instanceof CsvInputMeta) {
                    // check that stepError was copied
                    assertNotNull("Error hop was not copied", s.getStepErrorMeta());
                }
            }
            return null;
        }
    }).when(spoon).toClipboard(anyString());
    spoon.copySelected(transMeta, transMeta.getSelectedSteps(), Collections.<NotePadMeta>emptyList());
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) CsvInputMeta(org.pentaho.di.trans.steps.csvinput.CsvInputMeta) StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) RepositoryObject(org.pentaho.di.repository.RepositoryObject) Matchers.anyString(org.mockito.Matchers.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Test(org.junit.Test)

Example 27 with StepErrorMeta

use of org.pentaho.di.trans.step.StepErrorMeta in project pentaho-kettle by pentaho.

the class SpoonTest method testCopyPasteOneStepWithErrorHandling.

/**
 * test copy one step with error handling
 * @see http://jira.pentaho.com/browse/PDI-13358
 *
 * @throws KettleException
 */
@Test
public void testCopyPasteOneStepWithErrorHandling() throws KettleException {
    final TransMeta transMeta = new TransMeta();
    StepMeta sourceStep = new StepMeta("CsvInput", "Step1", new CsvInputMeta());
    StepMeta targetStep = new StepMeta("Dummy", "Dummy Step1", new DummyTransMeta());
    sourceStep.setSelected(true);
    transMeta.addStep(sourceStep);
    transMeta.addStep(targetStep);
    StepErrorMeta errorMeta = new StepErrorMeta(transMeta, sourceStep, targetStep);
    sourceStep.setStepErrorMeta(errorMeta);
    errorMeta.setSourceStep(sourceStep);
    errorMeta.setTargetStep(targetStep);
    final int stepsSizeBefore = transMeta.getSteps().size();
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            spoon.pasteXML(transMeta, (String) invocation.getArguments()[0], mock(Point.class));
            assertTrue("Steps was not copied", stepsSizeBefore < transMeta.getSteps().size());
            // selected copied step
            for (StepMeta s : transMeta.getSelectedSteps()) {
                if (s.getStepMetaInterface() instanceof CsvInputMeta) {
                    // check that stepError was empty, because we copy only one step from pair
                    assertNull("Error hop was not copied", s.getStepErrorMeta());
                }
            }
            return null;
        }
    }).when(spoon).toClipboard(anyString());
    spoon.copySelected(transMeta, transMeta.getSelectedSteps(), Collections.<NotePadMeta>emptyList());
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) CsvInputMeta(org.pentaho.di.trans.steps.csvinput.CsvInputMeta) StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) RepositoryObject(org.pentaho.di.repository.RepositoryObject) Matchers.anyString(org.mockito.Matchers.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Test(org.junit.Test)

Aggregations

StepErrorMeta (org.pentaho.di.trans.step.StepErrorMeta)27 StepMeta (org.pentaho.di.trans.step.StepMeta)22 TransHopMeta (org.pentaho.di.trans.TransHopMeta)10 Test (org.junit.Test)8 Point (org.pentaho.di.core.gui.Point)8 TransMeta (org.pentaho.di.trans.TransMeta)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)7 NotePadMeta (org.pentaho.di.core.NotePadMeta)6 KettleException (org.pentaho.di.core.exception.KettleException)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)5 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)5 StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)4 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 StepInterface (org.pentaho.di.trans.step.StepInterface)3 ArrayList (java.util.ArrayList)2 Matchers.anyString (org.mockito.Matchers.anyString)2