protected void onDriverItemClick(DriverDefInfo driverDefInfo) { placeManager.goTo(view.createEditorPlaceRequest(driverDefInfo.getPath())); }
private List<Pair<String, String>> buildDriverOptions(final List<DriverDefInfo> driverDefs) { List<Pair<String, String>> options = new ArrayList<>(); driverDefMap.clear(); for (DriverDefInfo driverDef : driverDefs) { options.add(new Pair<>(driverDef.getName(), driverDef.getUuid())); driverDefMap.put(driverDef.getUuid(), driverDef); } return options; }
@Override public DriverDefInfo findGlobalDriver(String uuid) { checkNotNull("uuid", uuid); for (DriverDefInfo driverDefInfo : findGlobalDrivers()) { if (uuid.equals(driverDefInfo.getUuid())) { return driverDefInfo; } } return null; }
private DriverDefInfo createDriverInfo(final org.uberfire.java.nio.file.Path path) { String content = ioService.readAllString(path); DriverDef driverDef = DriverDefSerializer.deserialize(content); DriverDeploymentInfo deploymentInfo = null; try { deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid()); } catch (Exception e) { logger.warn("It was not possible to read deployment info when building DriverDefInfo for driver: " + driverDef.getUuid(), e); } return new DriverDefInfo(driverDef.getUuid(), driverDef.getName(), Paths.convert(path), deploymentInfo); } }
public void loadDrivers(Collection<DriverDefInfo> driverDefInfos) { clearDrivers(); if (driverDefInfos != null) { DefItem item; for (DriverDefInfo driverDefInfo : driverDefInfos) { item = createItem(); item.setName(driverDefInfo.getName()); item.addItemHandler(new DefItemView.ItemHandler() { @Override public void onClick(String itemId) { onDriverItemClick(driverItemsMap.get(itemId)); } }); driverItemsMap.put(item.getId(), driverDefInfo); view.addDriverItem(item); } } }
@Override public DriverDefInfo findModuleDriver(final String uuid, final Path path) { checkNotNull("uuid", uuid); checkNotNull("path", path); for (DriverDefInfo driverDefInfo : findModuleDrivers(path)) { if (uuid.equals(driverDefInfo.getUuid())) { return driverDefInfo; } } return null; }
private void setupExpectedResults() { expectedDataSources = new ArrayList<>(); expectedDataSources.add( new DataSourceDefInfo("ds1Id", "DS1", Paths.convert(nioDataSourcesPath.resolve("DS1.datasource")), null)); expectedDataSources.add( new DataSourceDefInfo("ds2Id", "DS2", Paths.convert(nioDataSourcesPath.resolve("DS2.datasource")), null)); expectedDrivers = new ArrayList<>(); expectedDrivers.add( new DriverDefInfo("driver1Id", "Driver1", Paths.convert(nioDataSourcesPath.resolve("Driver1.driver")), null)); expectedDrivers.add( new DriverDefInfo("driver2Id", "Driver2", Paths.convert(nioDataSourcesPath.resolve("Driver2.driver")), null)); } }
@Before public void setup() { drivers = new ArrayList<>(); drivers.add(driver1); drivers.add(driver2); when(driver1.getName()).thenReturn("Driver1.name"); when(driver1.getUuid()).thenReturn(DRIVER_UUID); when(driver2.getName()).thenReturn("Driver2.name"); when(driver2.getUuid()).thenReturn(DRIVER_UUID_2); options = new ArrayList<>(); options.add(new Pair("Driver1.name", DRIVER_UUID)); options.add(new Pair("Driver2.name", DRIVER_UUID_2)); mainPanel = new DataSourceDefMainPanel(mainPanelView); clientValidationService = new ClientValidationServiceMock(); editorServiceCaller = new CallerMock<>(editorService); queryServiceCaller = new CallerMock<>(queryService); editorHelper = new DataSourceDefEditorHelper(translationService, editorServiceCaller, queryServiceCaller, clientValidationService, popupsUtil); editor = new DataSourceDefEditor(view, mainPanel, editorHelper, dbStructureExplorer, popupsUtil, placeManager, type, savePopupPresenter, deletePopUpPresenter, editorServiceCaller, dataSourceManagerClientCaller) { { this.versionRecordManager = DataSourceDefEditorTest.this.versionRecordManager; this.menuBuilder = mock(BasicFileMenuBuilder.class); } }; editor.init(); verify(view, times(1)).init(editor); verify(view, times(1)).setContent(mainPanel); }
@Override protected void deployDef(DriverDefInfo defInfo) { try { logger.debug("Deploying driver def: " + defInfo); String source = ioService.readAllString(Paths.convert(defInfo.getPath())); DriverDef driverDef = DriverDefSerializer.deserialize(source); runtimeManager.deployDriver(driverDef, DeploymentOptions.createOrResync()); defRegistry.setEntry(defInfo.getPath(), driverDef); logger.debug("Driver was successfully deployed"); } catch (Exception e) { logger.error("Driver deployment failed, defInfo: " + defInfo, e); } } }
public void onDriverChange() { DriverDefInfo driverDef = driverDefMap.get(mainPanel.getDriver()); driverValid = driverDef != null; if (!driverValid) { mainPanel.setDriverErrorMessage( getMessage(DataSourceManagementConstants.DataSourceDefEditor_DriverRequiredMessage)); dataSourceDef.setDriverUuid(null); } else { mainPanel.clearDriverErrorMessage(); dataSourceDef.setDriverUuid(driverDef.getUuid()); } if (handler != null) { handler.onDriverChange(); } }
/** * Initializes the services, the wizard pages, and drivers information. */ protected void setup() { //initialize the services editorServiceCaller = new CallerMock<>(editorService); queryServiceCaller = new CallerMock<>(queryService); //initialize the wizard page mainPanel = new DataSourceDefMainPanel(mainPanelView); dataSourceDef = new DataSourceDef(); editorHelper = new DataSourceDefEditorHelper(translationService, editorServiceCaller, queryServiceCaller, new ClientValidationServiceMock(), popupsUtil); defPage = new DataSourceDefPage(view, mainPanel, editorHelper, statusChangeEvent); defPage.setDataSourceDef(dataSourceDef); //prepare the drivers info drivers = new ArrayList<>(); drivers.add(driver1); drivers.add(driver2); options = new ArrayList<>(); options.add(new Pair("Driver1.name", DRIVER_UUID)); options.add(new Pair("Driver2.name", DRIVER_UUID_2)); when(driver1.getName()).thenReturn("Driver1.name"); when(driver1.getUuid()).thenReturn(DRIVER_UUID); when(driver2.getName()).thenReturn("Driver2.name"); when(driver2.getUuid()).thenReturn(DRIVER_UUID_2); //emulates the service returning the requested drivers. when(queryService.findModuleDrivers(path)).thenReturn(drivers); when(queryService.findGlobalDrivers()).thenReturn(drivers); }
/** * Tests that the driver def editor is properly launched when a data source is clicked. */ @Test public void testDriverDefClick() { PathPlaceRequestMock placeRequest = new PathPlaceRequestMock( driver1.getPath() ); when( view.createEditorPlaceRequest( driver1.getPath() ) ).thenReturn( placeRequest ); explorerContent.onDriverItemClick( driver1 ); verify( placeManager, times( 1 ) ).goTo( new PathPlaceRequestMock( driver1.getPath() ) ); }
@Before public void setup() { this.explorerContent = new DefExplorerContent( view, null, placeManager ) { @Override protected DefItem createItem() { return defItem; } @Override protected void onDataSourceItemClick( DataSourceDefInfo dataSourceDefInfo ) { super.onDataSourceItemClick( dataSourceDefInfo ); } }; driverDefInfos = new ArrayList<>( ); dataSourceDefInfos = new ArrayList<>( ); when( driver1.getPath() ).thenReturn( path1 ); when( driver2.getPath() ).thenReturn( path2 ); when( dataSource1.getPath() ).thenReturn( path3 ); when( dataSource1.isManaged() ).thenReturn( true ); when( dataSource2.getPath() ).thenReturn( path4 ); when( dataSource2.isManaged() ).thenReturn( true ); driverDefInfos.add( driver1 ); driverDefInfos.add( driver2 ); dataSourceDefInfos.add( dataSource1 ); dataSourceDefInfos.add( dataSource2 ); }
DriverDefEditorContent driverDefEditorContent = driverDefService.loadContent(driverDefInfo.getPath()); DriverDef driverDef = driverDefEditorContent.getDef(); URI uri;