Search in sources :

Example 96 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class SnapshotRedeployExecutorTest method testRedeploySingleServerTemplateUpdateServerWitException.

@Test
public void testRedeploySingleServerTemplateUpdateServerWitException() {
    doAnswer(invocationOnMock -> {
        throw new Exception();
    }).when(specManagementServiceMock).updateContainerSpec(anyString(), anyString(), any(), anyBoolean());
    final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
    serverTemplate.setMode(KieServerMode.DEVELOPMENT);
    ContainerSpec spec = mock(ContainerSpec.class);
    when(spec.getId()).thenReturn(context.getContainerId());
    when(spec.getStatus()).thenReturn(KieContainerStatus.STARTED);
    serverTemplate.addContainerSpec(spec);
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Collections.singletonList(serverTemplate)));
    runner.run(context);
    verify(buildDialog).startBuild();
    verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).updateContainerSpec(eq(SERVER_TEMPLATE_ID), eq(context.getContainerId()), containerSpecArgumentCaptor.capture(), eq(true));
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    assertEquals(KieContainerStatus.STARTED, containerSpec.getStatus());
    verifyNotification(CONSTANTS.DeployFailed(), NotificationEvent.NotificationType.ERROR);
    verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
    verify(buildDialog, atLeastOnce()).stopBuild();
    verify(deploymentPopup, never()).show(any());
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) AbstractBuildAndDeployExecutorTest(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.deploy.AbstractBuildAndDeployExecutorTest) Test(org.junit.Test)

Example 97 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class SnapshotRedeployExecutorTest method testRedeployWithMultipleTemplatesWithPreviousDeployment.

@Test
public void testRedeployWithMultipleTemplatesWithPreviousDeployment() {
    final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
    serverTemplate.setMode(KieServerMode.DEVELOPMENT);
    final ServerTemplate serverTemplate2 = new ServerTemplate(SERVER_TEMPLATE_ID2, SERVER_TEMPLATE_NAME2);
    serverTemplate2.setMode(KieServerMode.DEVELOPMENT);
    ContainerSpec spec = mock(ContainerSpec.class);
    when(spec.getId()).thenReturn(context.getContainerId());
    serverTemplate2.addContainerSpec(spec);
    when(settings.getDeployment(anyString(), anyString())).thenReturn(Optional.of(new SnapshotDeployment(GROUP, ARTIFACT, SERVER_TEMPLATE_ID2)));
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Arrays.asList(serverTemplate, serverTemplate2)));
    runner.run(context);
    verify(buildDialog).startBuild();
    verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).updateContainerSpec(eq(SERVER_TEMPLATE_ID2), eq(context.getContainerId()), containerSpecArgumentCaptor.capture(), eq(true));
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessfulAndContainerUpdated(), NotificationEvent.NotificationType.SUCCESS);
    verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
    verify(buildDialog, atLeastOnce()).stopBuild();
    verify(deploymentPopup, never()).show(any());
}
Also used : SnapshotDeployment(org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) AbstractBuildAndDeployExecutorTest(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.deploy.AbstractBuildAndDeployExecutorTest) Test(org.junit.Test)

Example 98 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class VariablesEditorWidgetViewImpl method getDataTypes.

protected void getDataTypes(final String value, final boolean fireEvents) {
    final List<String> simpleDataTypes = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Object", "String"));
    final List<String> simpleDataTypeDisplayNames = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Object", "String"));
    Set<String> types = StringUtils.getSetDataTypes(value);
    clientDataTypesService.call(presenter.getDiagramPath()).then(serverDataTypes -> {
        List<List<String>> mergedDataTypes = mergeDataTypes(simpleDataTypes, simpleDataTypeDisplayNames, serverDataTypes, types);
        setDataTypes(mergedDataTypes.get(0), mergedDataTypes.get(1));
        doSetValue(value, fireEvents, true);
        return null;
    }).catch_(exception -> {
        notification.fire(new NotificationEvent(StunnerFormsClientFieldsConstants.CONSTANTS.Error_retrieving_datatypes(), NotificationEvent.NotificationType.ERROR));
        setDataTypes(simpleDataTypes, simpleDataTypeDisplayNames);
        doSetValue(value, fireEvents, true);
        return null;
    });
}
Also used : ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) Arrays(java.util.Arrays) IconType(org.gwtbootstrap3.client.ui.constants.IconType) VariableRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HasValue(com.google.gwt.user.client.ui.HasValue) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ListBoxValues(org.kie.workbench.common.stunner.bpmn.client.forms.util.ListBoxValues) Composite(com.google.gwt.user.client.ui.Composite) Button(org.gwtbootstrap3.client.ui.Button) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) TableElement(com.google.gwt.dom.client.TableElement) Style(com.google.gwt.dom.client.Style) StringUtils(org.kie.workbench.common.stunner.bpmn.client.forms.util.StringUtils) Map(java.util.Map) Observes(javax.enterprise.event.Observes) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) DataField(org.jboss.errai.ui.shared.api.annotations.DataField) Event(javax.enterprise.event.Event) ListWidget(org.jboss.errai.ui.client.widget.ListWidget) TableCellElement(com.google.gwt.dom.client.TableCellElement) Set(java.util.Set) Table(org.jboss.errai.ui.client.widget.Table) Templated(org.jboss.errai.ui.shared.api.annotations.Templated) StunnerFormsClientFieldsConstants(org.kie.workbench.common.stunner.bpmn.client.forms.fields.i18n.StunnerFormsClientFieldsConstants) EventHandler(org.jboss.errai.ui.shared.api.annotations.EventHandler) List(java.util.List) TreeMap(java.util.TreeMap) Dependent(javax.enterprise.context.Dependent) Document(com.google.gwt.dom.client.Document) DataTypeNamesService(org.kie.workbench.common.stunner.bpmn.client.forms.DataTypeNamesService) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 99 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class ImportRepositoryPopUpPresenterTest method importEmptyRepositoryOnSuccessTest.

@Test
public void importEmptyRepositoryOnSuccessTest() {
    final String repositoryUrl = "repoUrl";
    final String repositoryAlias = "myRepository";
    final OrganizationalUnit orgUnit = mock(OrganizationalUnit.class);
    doThrow(new EmptyRemoteRepositoryException(repositoryAlias)).when(importService).getProjects(any(), any());
    doReturn(repositoryUrl).when(view).getRepositoryURL();
    doReturn(Optional.of(orgUnit)).when(projectContext).getActiveOrganizationalUnit();
    presenter.importRepository();
    verify(libraryService).createProject(orgUnit, repositoryUrl, repositoryAlias);
    verify(view, never()).showError(anyString());
    verify(view).hideBusyIndicator();
    verify(view).hide();
    verify(notificationEvent).fire(any(NotificationEvent.class));
    verify(libraryPlaces).goToProject(Mockito.<WorkspaceProject>any());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EmptyRemoteRepositoryException(org.kie.workbench.common.screens.examples.exception.EmptyRemoteRepositoryException) Test(org.junit.Test)

Example 100 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class ImportRepositoryPopUpPresenterTest method importEmptyRepositoryOnFailureTest.

@Test
public void importEmptyRepositoryOnFailureTest() {
    final String repositoryUrl = "repoUrl";
    final String repositoryAlias = "myRepository";
    final OrganizationalUnit orgUnit = mock(OrganizationalUnit.class);
    doThrow(new EmptyRemoteRepositoryException(repositoryAlias)).when(importService).getProjects(any(), any());
    doThrow(new RuntimeException()).when(libraryService).createProject(any(), anyString(), anyString());
    doReturn(repositoryUrl).when(view).getRepositoryURL();
    doReturn(Optional.of(orgUnit)).when(projectContext).getActiveOrganizationalUnit();
    presenter.importRepository();
    verify(view).showError(Mockito.<String>any());
    verify(view).hideBusyIndicator();
    verify(view, never()).hide();
    verify(notificationEvent, never()).fire(any(NotificationEvent.class));
    verify(libraryPlaces, never()).goToProject(Mockito.<WorkspaceProject>any());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EmptyRemoteRepositoryException(org.kie.workbench.common.screens.examples.exception.EmptyRemoteRepositoryException) Test(org.junit.Test)

Aggregations

NotificationEvent (org.uberfire.workbench.events.NotificationEvent)151 Test (org.junit.Test)65 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)34 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)28 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)22 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)21 List (java.util.List)17 Path (org.uberfire.backend.vfs.Path)17 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)16 ArrayList (java.util.ArrayList)14 Event (javax.enterprise.event.Event)14 Inject (javax.inject.Inject)12 ObservablePath (org.uberfire.backend.vfs.ObservablePath)12 PostConstruct (javax.annotation.PostConstruct)9 Observes (javax.enterprise.event.Observes)9 Caller (org.jboss.errai.common.client.api.Caller)9 Map (java.util.Map)8 Promise (elemental2.promise.Promise)7 Arrays (java.util.Arrays)7 Dependent (javax.enterprise.context.Dependent)7