Search in sources :

Example 31 with TransMeta

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

the class SpoonTest method testTransToRepSaveFileAs.

@Test
public void testTransToRepSaveFileAs() throws Exception {
    TransMeta mockTransMeta = mock(TransMeta.class);
    // passing a invalid type so not running GUIResource class
    prepareSetSaveTests(spoon, log, mockSpoonPerspective, mockTransMeta, false, false, MainSpoonPerspective.ID, true, true, "Invalid TYPE", null, true, true);
    doCallRealMethod().when(spoon).saveFileAs(mockTransMeta);
    assertTrue(spoon.saveFileAs(mockTransMeta));
    verify(mockTransMeta).setRepository(spoon.rep);
    verify(mockTransMeta).setMetaStore(spoon.metaStore);
    verify(mockTransMeta).setObjectId(null);
    verify(mockTransMeta).setFilename(null);
    verify(spoon.delegates.tabs).findTabMapEntry(mockTransMeta);
    verify(spoon).enableMenus();
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Test(org.junit.Test)

Example 32 with TransMeta

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

the class TransGraphTest method testInitializeXulMenu.

@SuppressWarnings("unchecked")
@Test
public void testInitializeXulMenu() throws KettleException {
    StepMeta stepMeta = mock(StepMeta.class);
    TransGraph transGraph = mock(TransGraph.class);
    TransMeta transMeta = mock(TransMeta.class);
    Document document = mock(Document.class);
    XulMenuitem xulItem = mock(XulMenuitem.class);
    XulMenu xulMenu = mock(XulMenu.class);
    StepErrorMeta stepErrorMeta = mock(StepErrorMeta.class);
    Spoon spoon = mock(Spoon.class);
    List<StepMeta> selection = Arrays.asList(new StepMeta(), stepMeta, new StepMeta());
    doCallRealMethod().when(transGraph).setTransMeta(any(TransMeta.class));
    doCallRealMethod().when(transGraph).setSpoon(any(Spoon.class));
    transGraph.setTransMeta(transMeta);
    transGraph.setSpoon(spoon);
    when(stepMeta.getStepErrorMeta()).thenReturn(stepErrorMeta);
    when(stepMeta.isDrawn()).thenReturn(true);
    when(document.getElementById(any(String.class))).thenReturn(xulItem);
    when(document.getElementById(TransGraph.TRANS_GRAPH_ENTRY_AGAIN)).thenReturn(xulMenu);
    when(document.getElementById(TransGraph.TRANS_GRAPH_ENTRY_SNIFF)).thenReturn(xulMenu);
    doCallRealMethod().when(transGraph).initializeXulMenu(any(Document.class), any(List.class), any(StepMeta.class));
    transGraph.initializeXulMenu(document, selection, stepMeta);
    verify(transMeta).isAnySelectedStepUsedInTransHops();
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) TransMeta(org.pentaho.di.trans.TransMeta) StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) List(java.util.List) Document(org.pentaho.ui.xul.dom.Document) StepMeta(org.pentaho.di.trans.step.StepMeta) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Test(org.junit.Test)

Example 33 with TransMeta

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

the class BaseStepDialog_ConnectionLine_Test method edits_WhenNewNameIsUnique.

@Test
public void edits_WhenNewNameIsUnique() throws Exception {
    TransMeta transMeta = new TransMeta();
    transMeta.addDatabase(createDefaultDatabase());
    invokeEditConnectionListener(transMeta, INPUT_NAME);
    assertOnlyDbExists(transMeta, INPUT_NAME, INPUT_HOST);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) Test(org.junit.Test)

Example 34 with TransMeta

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

the class BaseStepDialog_ConnectionLine_Test method edits_WhenNotRenamed.

@Test
public void edits_WhenNotRenamed() throws Exception {
    TransMeta transMeta = new TransMeta();
    transMeta.addDatabase(createDefaultDatabase());
    invokeEditConnectionListener(transMeta, INITIAL_NAME);
    assertOnlyDbExists(transMeta, INITIAL_NAME, INPUT_HOST);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) Test(org.junit.Test)

Example 35 with TransMeta

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

the class BaseStepDialog_ConnectionLine_Test method showDbDialog_LoopsUntilUniqueValueIsInput.

@Test
public void showDbDialog_LoopsUntilUniqueValueIsInput() throws Exception {
    DatabaseMeta db1 = createDefaultDatabase();
    DatabaseMeta db2 = createDefaultDatabase();
    db2.setName(INPUT_NAME);
    TransMeta transMeta = new TransMeta();
    transMeta.addDatabase(db1);
    transMeta.addDatabase(db2);
    final String expectedResult = INPUT_NAME + "2";
    DatabaseDialog databaseDialog = mock(DatabaseDialog.class);
    when(databaseDialog.open()).thenReturn(INPUT_NAME).thenReturn(INPUT_NAME + " ").thenReturn(INPUT_NAME.toUpperCase()).thenReturn(expectedResult);
    BaseStepDialog dialog = mock(BaseStepDialog.class);
    dialog.databaseDialog = databaseDialog;
    dialog.transMeta = transMeta;
    when(dialog.showDbDialogUnlessCancelledOrValid(anyDbMeta(), anyDbMeta())).thenCallRealMethod();
    when(dialog.getDatabaseDialog(any(Shell.class))).thenCallRealMethod();
    // try to rename db1 ("qwerty")
    String result = dialog.showDbDialogUnlessCancelledOrValid((DatabaseMeta) db1.clone(), db1);
    assertEquals(expectedResult, result);
    // database dialog should be shown four times
    verify(databaseDialog, times(4)).open();
    // and the error message should be shown three times
    verify(dialog, times(3)).showDbExistsDialog(anyDbMeta());
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TransMeta(org.pentaho.di.trans.TransMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) DatabaseDialog(org.pentaho.di.ui.core.database.dialog.DatabaseDialog) Test(org.junit.Test)

Aggregations

TransMeta (org.pentaho.di.trans.TransMeta)710 Test (org.junit.Test)289 StepMeta (org.pentaho.di.trans.step.StepMeta)234 Trans (org.pentaho.di.trans.Trans)214 KettleException (org.pentaho.di.core.exception.KettleException)150 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)136 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)117 TransHopMeta (org.pentaho.di.trans.TransHopMeta)115 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)109 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)106 StepInterface (org.pentaho.di.trans.step.StepInterface)76 RowStepCollector (org.pentaho.di.trans.RowStepCollector)73 JobMeta (org.pentaho.di.job.JobMeta)69 ArrayList (java.util.ArrayList)57 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)54 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)51 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)50 InjectorMeta (org.pentaho.di.trans.steps.injector.InjectorMeta)49 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)49 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)49