use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapConfirmationDialogTest method testOpen.
@Test
public void testOpen() throws XulException, KettleException {
Shell shell = mock(Shell.class);
final Document document = mock(Document.class);
SwtDialog swtDialog = mock(SwtDialog.class);
when(document.getElementById(DataServiceRemapConfirmationDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
DataServiceRemapConfirmationDialogController controller = mock(DataServiceRemapConfirmationDialogController.class);
DataServiceRemapConfirmationDialog dialog = spy(new DataServiceRemapConfirmationDialog(shell, controller));
doAnswer(new Answer() {
private int invocations = 0;
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
if (invocations == 0) {
invocations++;
return document;
} else {
throw new XulException("");
}
}
}).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
dialog.open();
verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
verify(swtDialog).show();
try {
dialog.open();
} catch (Exception e) {
Assert.assertTrue(e instanceof KettleException);
}
}
use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapNoStepsDialogTest method testOpen.
@Test
public void testOpen() throws XulException, KettleException {
Shell shell = mock(Shell.class);
final Document document = mock(Document.class);
SwtDialog swtDialog = mock(SwtDialog.class);
when(document.getElementById(DataServiceRemapNoStepsDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
DataServiceRemapNoStepsDialogController controller = mock(DataServiceRemapNoStepsDialogController.class);
DataServiceRemapNoStepsDialog dialog = spy(new DataServiceRemapNoStepsDialog(shell, controller));
doAnswer(new Answer() {
private int invocations = 0;
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
if (invocations == 0) {
invocations++;
return document;
} else {
throw new XulException("");
}
}
}).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
dialog.open();
verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
verify(swtDialog).show();
try {
dialog.open();
} catch (Exception e) {
Assert.assertTrue(e instanceof KettleException);
}
}
use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapStepChooserDialogTest method testOpen.
@Test
public void testOpen() throws XulException, KettleException {
Shell shell = mock(Shell.class);
final Document document = mock(Document.class);
SwtDialog swtDialog = mock(SwtDialog.class);
when(document.getElementById(DataServiceRemapStepChooserDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
DataServiceRemapStepChooserDialogController controller = mock(DataServiceRemapStepChooserDialogController.class);
DataServiceRemapStepChooserDialog dialog = spy(new DataServiceRemapStepChooserDialog(shell, controller));
doAnswer(new Answer() {
private int invocations = 0;
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
if (invocations == 0) {
invocations++;
return document;
} else {
throw new XulException("");
}
}
}).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
dialog.open();
verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
verify(swtDialog).show();
try {
dialog.open();
} catch (Exception e) {
Assert.assertTrue(e instanceof KettleException);
}
}
use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.
the class DriverDetailsDialogTest method testOpen.
@Test
public void testOpen() throws Exception {
DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
doCallRealMethod().when(dialog).open();
SwtDialog swtDialog = mock(SwtDialog.class);
doReturn(swtDialog).when(dialog).getDialog();
dialog.open();
verify(dialog).getDialog();
verify(swtDialog).show();
}
use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.
the class DriverDetailsDialogTest method testClose.
@Test
public void testClose() throws Exception {
DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
doCallRealMethod().when(dialog).close();
SwtDialog swtDialog = mock(SwtDialog.class);
doReturn(swtDialog).when(dialog).getDialog();
dialog.close();
verify(dialog).getDialog();
verify(swtDialog).dispose();
}
Aggregations