Search in sources :

Example 1 with Document

use of org.pentaho.ui.xul.dom.Document 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 2 with Document

use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.

the class DataHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    dataHandler = new DataHandler();
    xulDomContainer = mock(XulDomContainer.class);
    document = mock(Document.class);
    XulComponent rootElement = mock(XulComponent.class);
    when(document.getRootElement()).thenReturn(rootElement);
    // Mock the UI components
    accessBox = mock(XulListbox.class);
    when(document.getElementById("access-type-list")).thenReturn(accessBox);
    connectionBox = mock(XulListbox.class);
    when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
    connectionNameBox = mock(XulTextbox.class);
    when(document.getElementById("connection-name-text")).thenReturn(connectionNameBox);
    dialogDeck = mock(XulDeck.class);
    when(document.getElementById("dialog-panel-deck")).thenReturn(dialogDeck);
    deckOptionsBox = mock(XulListbox.class);
    when(document.getElementById("deck-options-list")).thenReturn(deckOptionsBox);
    hostNameBox = mock(XulTextbox.class);
    when(document.getElementById("server-host-name-text")).thenReturn(hostNameBox);
    databaseNameBox = mock(XulTextbox.class);
    when(document.getElementById("database-name-text")).thenReturn(databaseNameBox);
    portNumberBox = mock(XulTextbox.class);
    when(document.getElementById("port-number-text")).thenReturn(portNumberBox);
    userNameBox = mock(XulTextbox.class);
    when(document.getElementById("username-text")).thenReturn(userNameBox);
    passwordBox = mock(XulTextbox.class);
    when(document.getElementById("password-text")).thenReturn(passwordBox);
    serverInstanceBox = mock(XulTextbox.class);
    when(document.getElementById("instance-text")).thenReturn(serverInstanceBox);
    when(serverInstanceBox.getValue()).thenReturn("instance");
    when(serverInstanceBox.getAttributeValue("shouldDisablePortIfPopulated")).thenReturn("true");
    webappName = mock(XulTextbox.class);
    when(document.getElementById("web-application-name-text")).thenReturn(webappName);
    when(webappName.getValue()).thenReturn("webappName");
    messageBox = mock(XulMessageBox.class);
    when(document.createElement("messagebox")).thenReturn(messageBox);
    when(xulDomContainer.getDocumentRoot()).thenReturn(document);
    generalDatasourceWindow = mock(XulRoot.class);
    when(generalDatasourceWindow.getRootObject()).thenReturn(mock(XulComponent.class));
    when(document.getElementById("general-datasource-window")).thenReturn(generalDatasourceWindow);
    dataHandler.setXulDomContainer(xulDomContainer);
}
Also used : XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulDeck(org.pentaho.ui.xul.containers.XulDeck) XulRoot(org.pentaho.ui.xul.containers.XulRoot) XulListbox(org.pentaho.ui.xul.containers.XulListbox) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent) Before(org.junit.Before)

Example 3 with Document

use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.

the class FragmentHandlerTest method testLoadDatabaseOptionsFragment.

@Test
public void testLoadDatabaseOptionsFragment() throws Exception {
    XulComponent component = mock(XulComponent.class);
    XulComponent parent = mock(XulComponent.class);
    when(component.getParent()).thenReturn(parent);
    when(document.getElementById("database-options-box")).thenReturn(component);
    XulDomContainer fragmentContainer = mock(XulDomContainer.class);
    Document mockDoc = mock(Document.class);
    XulComponent firstChild = mock(XulComponent.class);
    when(mockDoc.getFirstChild()).thenReturn(firstChild);
    when(fragmentContainer.getDocumentRoot()).thenReturn(mockDoc);
    when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenReturn(fragmentContainer);
    fragmentHandler.loadDatabaseOptionsFragment(null);
}
Also used : XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent) Test(org.junit.Test)

Example 4 with Document

use of org.pentaho.ui.xul.dom.Document in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapNoStepsDialog method open.

void open() throws KettleException {
    Document xulDocument;
    try {
        xulDocument = initXul(parent, new KettleXulLoader(), new SwtXulRunner());
    } catch (XulException xulException) {
        throw new KettleException("Failed to initialize RemapNoStepsDialog.", xulException);
    }
    ((SwtDialog) xulDocument.getElementById(XUL_DIALOG_ID)).show();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) Document(org.pentaho.ui.xul.dom.Document) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 5 with Document

use of org.pentaho.ui.xul.dom.Document in project pdi-dataservice-server-plugin by pentaho.

the class DriverDetailsDialogTest method testInitXul.

@Test
public void testInitXul() throws Exception {
    DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
    Shell parentShell = mock(Shell.class);
    AbstractXulLoader xulLoader = mock(AbstractXulLoader.class);
    XulRunner xulRunner = mock(XulRunner.class);
    Document document = mock(Document.class);
    XulDomContainer container = mock(XulDomContainer.class);
    doReturn(container).when(xulLoader).loadXul(anyString(), any(ResourceBundle.class));
    doReturn(document).when(container).getDocumentRoot();
    doCallRealMethod().when(dialog).initXul(parentShell, xulLoader, xulRunner);
    assertThat(document, is(sameInstance(dialog.initXul(parentShell, xulLoader, xulRunner))));
    verify(xulLoader).setOuterContext(parentShell);
    verify(xulLoader).registerClassLoader(dialog.getClass().getClassLoader());
    verify(xulLoader).loadXul(anyString(), any(ResourceBundle.class));
    verify(container).addEventHandler(any(DriverDetailsDialogController.class));
    verify(container).getDocumentRoot();
    verify(xulRunner).addContainer(container);
    verify(xulRunner).initialize();
}
Also used : DriverDetailsDialogController(org.pentaho.di.trans.dataservice.ui.controller.DriverDetailsDialogController) Shell(org.eclipse.swt.widgets.Shell) AbstractXulLoader(org.pentaho.ui.xul.impl.AbstractXulLoader) ResourceBundle(java.util.ResourceBundle) Document(org.pentaho.ui.xul.dom.Document) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Aggregations

Document (org.pentaho.ui.xul.dom.Document)17 Test (org.junit.Test)7 KettleException (org.pentaho.di.core.exception.KettleException)7 XulException (org.pentaho.ui.xul.XulException)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)5 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)5 Shell (org.eclipse.swt.widgets.Shell)4 XulComponent (org.pentaho.ui.xul.XulComponent)4 XulRunner (org.pentaho.ui.xul.XulRunner)4 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)4 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 XulMenu (org.pentaho.ui.xul.containers.XulMenu)3 Action (org.eclipse.jface.action.Action)2 Before (org.junit.Before)2 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2 Point (org.pentaho.di.core.gui.Point)2