Search in sources :

Example 61 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class ActiveOptionsInitTest method testNoParameters.

@Test
public void testNoParameters() throws Exception {
    Command completeCommand = mock(Command.class);
    options.init(mock(PlaceRequest.class), completeCommand);
    assertFalse(options.getOptions().isEmpty());
    assertTrue(options.isBusinessViewActive());
    assertTrue(options.isBreadCrumbNavigationVisible());
    assertFalse(options.areHiddenFilesVisible());
    verify(completeCommand).execute();
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 62 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class BuildExecutorTest method testBuildNotManagedRepositoryClashingGAV.

@Test
@SuppressWarnings("unchecked")
public void testBuildNotManagedRepositoryClashingGAV() throws Exception {
    final Map<String, Object> env = new HashMap<String, Object>() {

        {
            put("managed", false);
        }
    };
    when(repository.getEnvironment()).thenReturn(env);
    doThrow(GAVAlreadyExistsException.class).when(buildServiceMock).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED));
    final GAV gav = module.getPom().getGav();
    final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
    buildExecutor.triggerBuildAndDeploy();
    verify(buildServiceMock, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED));
    verify(conflictingRepositoriesPopup, times(1)).setContent(eq(gav), any(Set.class), commandArgumentCaptor.capture());
    verify(conflictingRepositoriesPopup, times(1)).show();
    assertNotNull(commandArgumentCaptor.getValue());
    // Emulate User electing to force save
    commandArgumentCaptor.getValue().execute();
    verify(conflictingRepositoriesPopup, times(1)).hide();
    verify(buildServiceMock, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.FORCED));
    verify(view, times(2)).showBusyIndicator(eq(ProjectEditorResources.CONSTANTS.Building()));
    verify(view, times(2)).hideBusyIndicator();
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) Command(org.uberfire.mvp.Command) Matchers.anyString(org.mockito.Matchers.anyString) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 63 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class NewWorkspaceProjectHandlerTest method testGetCommandWithActiveRepository.

@Test
public void testGetCommandWithActiveRepository() {
    final LibraryOrganizationalUnitPreferences libraryOrganizationalUnitPreferences = mock(LibraryOrganizationalUnitPreferences.class);
    when(libraryOrganizationalUnitPreferences.getName()).thenReturn("myOU");
    when(libraryPreferences.getOrganizationalUnitPreferences()).thenReturn(libraryOrganizationalUnitPreferences);
    when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(Module.class))));
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getDefaultGroupId()).thenReturn("defaultGroupId");
    when(organizationalUnitService.getOrganizationalUnit("myOU")).thenReturn(organizationalUnit);
    doAnswer(new Answer() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            when(context.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
            return null;
        }
    }).when(projectContextChangeEvent).fire(any(WorkspaceProjectContextChangeEvent.class));
    final Command command = handler.getCommand(newResourcePresenter);
    assertNotNull(command);
    command.execute();
    ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
    verify(wizard, times(1)).initialise(pomArgumentCaptor.capture());
    verify(wizard, times(1)).start(any(org.uberfire.client.callbacks.Callback.class), anyBoolean());
    assertEquals("defaultGroupId", pomArgumentCaptor.getValue().getGav().getGroupId());
    assertEquals("kjar", pomArgumentCaptor.getValue().getPackaging());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) POM(org.guvnor.common.services.project.model.POM) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LibraryOrganizationalUnitPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences) Callback(com.google.gwt.core.client.Callback) ValidatorWithReasonCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorWithReasonCallback) Command(org.uberfire.mvp.Command) Branch(org.guvnor.structure.repositories.Branch) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 64 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class NewWorkspaceProjectWizardTest method testCompleteClashingGAV.

@Test
@SuppressWarnings("unchecked")
public void testCompleteClashingGAV() throws Exception {
    final Path repositoryRoot = mock(Path.class);
    final POM pom = mock(POM.class);
    final GAV gav = mock(GAV.class);
    when(projectService.newProject(any(OrganizationalUnit.class), eq(pom), eq(DeploymentMode.VALIDATED))).thenThrow(GAVAlreadyExistsException.class);
    when(moduleContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(mock(OrganizationalUnit.class)));
    when(moduleContext.getActiveRepositoryRoot()).thenReturn(Optional.of(repositoryRoot));
    when(pomWizardPage.getPom()).thenReturn(pom);
    when(pom.getGav()).thenReturn(gav);
    final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
    wizard.complete();
    verify(projectService, timeout(1)).newProject(any(OrganizationalUnit.class), eq(pom), eq(DeploymentMode.VALIDATED));
    verify(busyIndicatorView, times(1)).showBusyIndicator(any(String.class));
    verify(busyIndicatorView, times(1)).hideBusyIndicator();
    verify(conflictingRepositoriesPopup, times(1)).setContent(eq(gav), any(Set.class), commandArgumentCaptor.capture());
    verify(conflictingRepositoriesPopup, times(1)).show();
    assertNotNull(commandArgumentCaptor.getValue());
    // Emulate User electing to force save
    commandArgumentCaptor.getValue().execute();
    verify(conflictingRepositoriesPopup, times(1)).hide();
    verify(projectService, times(1)).newProject(any(OrganizationalUnit.class), eq(pom), eq(DeploymentMode.FORCED));
    verify(busyIndicatorView, times(2)).showBusyIndicator(any(String.class));
    verify(busyIndicatorView, times(2)).hideBusyIndicator();
}
Also used : Path(org.uberfire.backend.vfs.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Set(java.util.Set) Command(org.uberfire.mvp.Command) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 65 with Command

use of org.uberfire.mvp.Command 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)

Aggregations

Command (org.uberfire.mvp.Command)117 Test (org.junit.Test)66 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)15 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)11 Group (com.ait.lienzo.client.core.shape.Group)9 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)9 Before (org.junit.Before)8 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)7 Path (org.uberfire.backend.vfs.Path)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 Inject (javax.inject.Inject)4 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 DeleteHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand)4 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)4 SetHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand)4