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();
}
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();
}
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);
}
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);
}
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());
}
Aggregations