DataServiceRemapNoStepsDialog { 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(); } DataServiceRemapNoStepsDialog( Shell parent, DataServiceRemapNoStepsDialogController controller );  static final String XUL_DIALOG_ID; }
@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 ); } }