Search in sources :

Example 1 with ClientValidationServiceMock

use of org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock in project kie-wb-common by kiegroup.

the class DriverDefEditorHelperTest method setup.

@Before
public void setup() {
    clientValidationService = new ClientValidationServiceMock();
    editorHelper = new DriverDefEditorHelper(translationService, clientValidationService);
    editorHelper.setHandler(handler);
    editorHelper.init(mainPanel);
    driverDef = new DriverDef();
    editorHelper.setDriverDef(driverDef);
    verify(mainPanel, times(1)).clear();
    verify(mainPanel, times(1)).setName(driverDef.getName());
    verify(mainPanel, times(1)).setDriverClass(driverDef.getDriverClass());
    verify(mainPanel, times(1)).setGroupId(driverDef.getGroupId());
    verify(mainPanel, times(1)).setArtifactId(driverDef.getArtifactId());
    verify(mainPanel, times(1)).setVersion(driverDef.getVersion());
}
Also used : DriverDef(org.kie.workbench.common.screens.datasource.management.model.DriverDef) ClientValidationServiceMock(org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock) Before(org.junit.Before)

Example 2 with ClientValidationServiceMock

use of org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock in project kie-wb-common by kiegroup.

the class DriverDefEditorTest method setup.

@Before
public void setup() {
    mainPanel = new DriverDefMainPanel(mainPanelView);
    clientValidationService = new ClientValidationServiceMock();
    editorHelper = new DriverDefEditorHelper(translationService, clientValidationService);
    editorServiceCaller = new CallerMock<>(editorService);
    dataSourceManagerClientCaller = new CallerMock<>(dataSourceManagerClient);
    editor = new DriverDefEditor(view, mainPanel, editorHelper, popupsUtil, placeManager, type, savePopupPresenter, deletePopUpPresenter, editorServiceCaller, dataSourceManagerClientCaller) {

        {
            this.versionRecordManager = DriverDefEditorTest.this.versionRecordManager;
            this.menuBuilder = mock(BasicFileMenuBuilder.class);
        }
    };
    verify(view, times(1)).init(editor);
    verify(view, times(1)).setContent(mainPanel);
}
Also used : ClientValidationServiceMock(org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock) Before(org.junit.Before)

Example 3 with ClientValidationServiceMock

use of org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock in project kie-wb-common by kiegroup.

the class DataSourceWizardTestBase method setup.

/**
 * 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);
}
Also used : DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) DataSourceDefMainPanel(org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefMainPanel) DataSourceDefEditorHelper(org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefEditorHelper) ClientValidationServiceMock(org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock) Pair(org.uberfire.commons.data.Pair)

Example 4 with ClientValidationServiceMock

use of org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock in project kie-wb-common by kiegroup.

the class DataSourceDefEditorHelperTest method setup.

@Before
public void setup() {
    clientValidationService = new ClientValidationServiceMock();
    editorServiceCaller = new CallerMock<>(editorService);
    queryServiceCaller = new CallerMock<>(queryService);
    when(driverDefInfo.getUuid()).thenReturn(DRIVER_UUID);
    when(driverDefInfo.getName()).thenReturn("DriverName");
    List<DriverDefInfo> drivers = new ArrayList<>();
    drivers.add(driverDefInfo);
    when(queryService.findGlobalDrivers()).thenReturn(drivers);
    when(queryService.findModuleDrivers(any(Path.class))).thenReturn(drivers);
    editorHelper = new DataSourceDefEditorHelper(translationService, editorServiceCaller, queryServiceCaller, clientValidationService, popupsUtil);
    editorHelper.setHandler(handler);
    editorHelper.init(mainPanel);
    editorHelper.loadDrivers(new Command() {

        @Override
        public void execute() {
        // do nothing
        }
    }, new ParameterizedCommand<Throwable>() {

        @Override
        public void execute(Throwable parameter) {
        // do nothing
        }
    });
    dataSourceDef = new DataSourceDef();
    editorHelper.setDataSourceDef(dataSourceDef);
    verify(mainPanel, times(1)).clear();
    verify(mainPanel, times(1)).setName(dataSourceDef.getName());
    verify(mainPanel, times(1)).setConnectionURL(dataSourceDef.getConnectionURL());
    verify(mainPanel, times(1)).setUser(dataSourceDef.getUser());
    verify(mainPanel, times(1)).setPassword(dataSourceDef.getPassword());
    verify(mainPanel, times(1)).setDriver(dataSourceDef.getDriverUuid());
}
Also used : Path(org.uberfire.backend.vfs.Path) DriverDefInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ArrayList(java.util.ArrayList) DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) ClientValidationServiceMock(org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock) Before(org.junit.Before)

Example 5 with ClientValidationServiceMock

use of org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock in project kie-wb-common by kiegroup.

the class DataSourceDefEditorTest method setup.

@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);
}
Also used : ClientValidationServiceMock(org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock) Pair(org.uberfire.commons.data.Pair) Before(org.junit.Before)

Aggregations

ClientValidationServiceMock (org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock)6 Before (org.junit.Before)4 DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)2 DriverDef (org.kie.workbench.common.screens.datasource.management.model.DriverDef)2 Pair (org.uberfire.commons.data.Pair)2 ArrayList (java.util.ArrayList)1 DataSourceDefEditorHelper (org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefEditorHelper)1 DataSourceDefMainPanel (org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefMainPanel)1 DriverDefEditorHelper (org.kie.workbench.common.screens.datasource.management.client.editor.driver.DriverDefEditorHelper)1 DriverDefMainPanel (org.kie.workbench.common.screens.datasource.management.client.editor.driver.DriverDefMainPanel)1 DriverDefInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)1 Path (org.uberfire.backend.vfs.Path)1 Command (org.uberfire.mvp.Command)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1