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; }
@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; }
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(); } }
@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); }
/** * 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); }
when(driverDefInfo.getUuid()).thenReturn(DRIVER_UUID); when(driverDefInfo.getName()).thenReturn("DriverName"); List<DriverDefInfo> drivers = new ArrayList<>();