@Override public void execute() { mainPanel.setDriver(getContent().getDef().getDriverUuid()); } };
protected void setContent(final DataSourceDefEditorContent editorContent) { this.editorContent = editorContent; view.setDataSourceName(editorContent.getDef().getName()); editorHelper.setDataSourceDef(editorContent.getDef()); editorHelper.setModule(editorContent.getModule()); editorHelper.setValid(true); }
private DataSourceDefEditorContent createContent() { DataSourceDefEditorContent content = new DataSourceDefEditorContent(); content.setDef(new DataSourceDef()); content.getDef().setName(NAME); content.getDef().setDriverUuid(DRIVER_UUID); content.getDef().setConnectionURL(CONNECTION_URL); content.getDef().setUser(USER); content.getDef().setPassword(PASSWORD); return content; } }
@Override public void onShowContent() { DatabaseStructureExplorer.Settings settings = new DatabaseStructureExplorer.Settings() .dataSourceUuid(getContent().getDef().getUuid()) .dataSourceName(getContent().getDef().getName()); dbStructureExplorer.initialize(settings, new InitializeCallback() { @Override public void onInitializeError(Throwable throwable) { // do nothing, just stay showing the parameters edition. } @Override public void onInitializeSuccess() { showContent(); } }); }
@Test public void testLoadFileSuccessFul() { prepareLoadFileSuccessful(); //verifies the content was properly loaded. verify(view, times(1)).showLoading(); verify(view, times(1)).hideBusyIndicator(); assertEquals(content, editor.getContent()); verify(mainPanelView, times(1)).loadDriverOptions(eq(options), eq(true)); verify(mainPanelView, times(1)).setName(content.getDef().getName()); verify(mainPanelView, times(1)).setConnectionURL(content.getDef().getConnectionURL()); verify(mainPanelView, times(1)).setUser(content.getDef().getUser()); verify(mainPanelView, times(1)).setPassword(content.getDef().getPassword()); verify(mainPanelView, times(2)).setDriver(content.getDef().getDriverUuid()); }
/** * Checks current data source status prior to execute an update operation. */ protected void executeSafeUpdateCommand(String onDependantsMessageKey, Command defaultCommand, Command yesCommand, Command noCommand) { dataSourceManagerClient.call(new RemoteCallback<DataSourceDeploymentInfo>() { @Override public void callback(DataSourceDeploymentInfo deploymentInfo) { if (deploymentInfo != null && deploymentInfo.wasReferenced()) { popupsUtil.showYesNoPopup(CommonConstants.INSTANCE.Warning(), editorHelper.getMessage(onDependantsMessageKey), yesCommand, CommonConstants.INSTANCE.YES(), ButtonType.WARNING, noCommand, CommonConstants.INSTANCE.NO(), ButtonType.DEFAULT); } else { defaultCommand.execute(); } } }).getDataSourceDeploymentInfo(getContent().getDef().getUuid()); }
@Test public void testOnBrowseDatabase() { //open the editor with a valid content prepareLoadFileSuccessful(); //emulates the selection of the show content action from the UI editor.onShowContent(); DatabaseStructureExplorer.Settings expectedSettings = new DatabaseStructureExplorer.Settings(); expectedSettings.dataSourceUuid(content.getDef().getUuid()); expectedSettings.dataSourceName(content.getDef().getName()); //dbStructureExplorer should have been initialized with the proper datasource parameters. verify(dbStructureExplorer, times(1)).initialize(eq(expectedSettings), any(InitializeCallback.class)); }
@Test public void testEditorChanges() { //open the editor with a valid content prepareLoadFileSuccessful(); //emulates some valid changes in the editor. when(mainPanelView.getName()).thenReturn(NAME_2); when(mainPanelView.getConnectionURL()).thenReturn(CONNECTION_URL_2); when(mainPanelView.getUser()).thenReturn(USER_2); when(mainPanelView.getPassword()).thenReturn(PASSWORD_2); when(mainPanelView.getDriver()).thenReturn(DRIVER_UUID_2); mainPanel.onNameChange(); mainPanel.onConnectionURLChange(); mainPanel.onUserChange(); mainPanel.onPasswordChange(); mainPanel.onDriverChange(); //the content of the editor should have been properly modified. assertEquals(NAME_2, content.getDef().getName()); assertEquals(CONNECTION_URL_2, content.getDef().getConnectionURL()); assertEquals(USER_2, content.getDef().getUser()); assertEquals(PASSWORD_2, content.getDef().getPassword()); assertEquals(DRIVER_UUID_2, content.getDef().getDriverUuid()); }