Search in sources :

Example 86 with NotificationEvent

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

the class DataModelerScreenPresenter method getDeleteSuccessCallback.

private RemoteCallback<Path> getDeleteSuccessCallback() {
    return new RemoteCallback<Path>() {

        @Override
        public void callback(final Path response) {
            view.hideBusyIndicator();
            notification.fire(new NotificationEvent(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.ItemDeletedSuccessfully(), NotificationEvent.NotificationType.SUCCESS));
        }
    };
}
Also used : ObservablePath(org.uberfire.backend.vfs.ObservablePath) Path(org.uberfire.backend.vfs.Path) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 87 with NotificationEvent

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

the class SnapshotBuildAndDeployExecutorTest method testBuildAndDeploySingleServerTemplateWithoutStart.

@Test
public void testBuildAndDeploySingleServerTemplateWithoutStart() {
    final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
    serverTemplate.setMode(KieServerMode.DEVELOPMENT);
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Collections.singletonList(serverTemplate)));
    context.setStartContainer(false);
    runner.run(context);
    verify(buildDialog).startBuild();
    verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).saveContainerSpec(eq(serverTemplate.getId()), containerSpecArgumentCaptor.capture());
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verify(specManagementServiceMock, never()).startContainer(any());
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS);
    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) Test(org.junit.Test)

Example 88 with NotificationEvent

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

the class SnapshotBuildAndDeployExecutorTest method testBuildAndDeploySingleServerTemplateUpdateServerWitException.

@Test
public void testBuildAndDeploySingleServerTemplateUpdateServerWitException() {
    doAnswer(invocationOnMock -> {
        throw new Exception();
    }).when(specManagementServiceMock).updateContainerSpec(anyString(), any());
    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());
    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), containerSpecArgumentCaptor.capture());
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    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) Test(org.junit.Test)

Example 89 with NotificationEvent

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

the class SnapshotBuildAndDeployExecutorTest method testBuildAndDeploySingleServerTemplateUpdateServer.

@Test
public void testBuildAndDeploySingleServerTemplateUpdateServer() {
    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());
    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), containerSpecArgumentCaptor.capture());
    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 : 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) Test(org.junit.Test)

Example 90 with NotificationEvent

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

the class SnapshotBuildAndDeployExecutorTest method testBuildAndDeployWithMultipleTemplatesWithPreviousDeployment.

@Test
public void testBuildAndDeployWithMultipleTemplatesWithPreviousDeployment() {
    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), containerSpecArgumentCaptor.capture());
    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) 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