Search in sources :

Example 11 with NotificationEvent

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

the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsDuplicated.

@Test
public void testMakeDragProxyCallbackImplWhenNodeIsDuplicated() {
    final ShapeFactory factory = mock(ShapeFactory.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final int x = 10;
    final int y = 20;
    final String expectedWarnMessage = "This 'DRGElement' already exists!";
    final NotificationEvent.NotificationType expectedWarnType = WARNING;
    final Graph<?, Node> graph = mock(Graph.class);
    final List<Node> nodes = new ArrayList<>();
    final String id1 = "123";
    final String id2 = "123";
    nodes.add(createNode(id1));
    nodes.add(createNode(id2));
    when(graph.nodes()).thenReturn(nodes);
    when(drgElement.getId()).thenReturn(new Id(id1));
    when(clientTranslationService.getValue(DecisionComponentsItemView_DuplicatedNode)).thenReturn(expectedWarnMessage);
    doReturn(graph).when(view).getGraph();
    view.setIsImported(true);
    view.makeDragProxyCallbackImpl(drgElement, factory).onComplete(x, y);
    verify(buildCanvasShapeEvent, never()).fire(any());
    verify(notificationEvent).fire(notificationEventArgumentCaptor.capture());
    final NotificationEvent notificationEvent = notificationEventArgumentCaptor.getValue();
    assertEquals(expectedWarnMessage, notificationEvent.getNotification());
    assertEquals(expectedWarnType, notificationEvent.getType());
}
Also used : DecisionComponentsItemView_DuplicatedNode(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) DMNShapeFactory(org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 12 with NotificationEvent

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

the class ProviderPresenterTest method testRemoveProvider.

private void testRemoveProvider(boolean withErrors) {
    // emulate that the provider was previously loaded.
    prepareRuntimesInfo();
    presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
    when(view.getRemoveProviderSuccessMessage()).thenReturn(SUCCESS_MESSAGE);
    when(view.getRemoveProviderErrorMessage()).thenReturn(ERROR_MESSAGE);
    if (withErrors) {
        // make the providerService fail.
        prepareServiceCallerError(providerService, providerServiceCaller);
    }
    // the user confirms the delete operation at a later time from the ui.
    presenter.removeProvider();
    verify(providerService, times(1)).deleteProvider(providerKey);
    verify(providerTypeSelectedEvent, times(1)).fire(new ProviderTypeSelectedEvent(providerKey.getProviderTypeKey()));
    if (withErrors) {
        verify(notification, times(1)).fire(new NotificationEvent(ERROR_MESSAGE, NotificationEvent.NotificationType.ERROR));
    } else {
        verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
    }
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) ProviderTypeSelectedEvent(org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 13 with NotificationEvent

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

the class RuntimePresenterActionsTest method testDeletePipelineConfirmYesAndSuccessful.

@Test
public void testDeletePipelineConfirmYesAndSuccessful() {
    preparePipelineDelete();
    PipelineExecutionTraceKey currentKey = trace.getKey();
    when(translationService.format(RuntimePresenter_PipelineExecutionDeleteSuccessMessage, currentKey.getId())).thenReturn(SUCCESS_MESSAGE);
    yesCommandCaptor.getValue().execute();
    verify(runtimeService, times(1)).deletePipelineExecution(currentKey);
    verify(notificationEvent, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) PipelineExecutionTraceKey(org.guvnor.ala.ui.model.PipelineExecutionTraceKey) Test(org.junit.Test)

Example 14 with NotificationEvent

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

the class NewDeployWizardTest method testStartDeploymentSuccess.

@Test
public void testStartDeploymentSuccess() {
    // initialize and start the wizard.
    wizard.start(provider, pipelines);
    verifyStart();
    // e.g. PIPELINE1 was selected.
    preSelectForms(PIPELINE1_KEY);
    // emulate the user completing the wizard.
    preCompleteWizard(PIPELINE1_KEY, RUNTIME);
    // emulates the user pressing the finish button
    wizard.complete();
    // the parameters must the the values collected by the forms.
    Map<String, String> expectedPrams = buildExpectedParams(paramsFormsValues);
    expectedPrams.put(RUNTIME_NAME, RUNTIME);
    verify(runtimeService, times(1)).createRuntime(provider.getKey(), RUNTIME, PIPELINE1_KEY, expectedPrams);
    verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
    verify(refreshRuntimeEvent, times(1)).fire(new RefreshRuntimeEvent(provider.getKey()));
}
Also used : RefreshRuntimeEvent(org.guvnor.ala.ui.client.events.RefreshRuntimeEvent) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 15 with NotificationEvent

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

the class EnableProviderTypeWizardTest method testEnableProviderSuccess.

@Test
public void testEnableProviderSuccess() {
    // initialize and start the wizard.
    wizard.start(providerTypeStatus);
    // emulate the user completing the wizard.
    preCompleteWizard();
    // emulates the user pressing the finish button
    wizard.complete();
    // verify the provider types has been enabled and the proper notifications were fired.
    verify(providerTypeService, times(1)).enableProviderTypes(selectedProviders);
    verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
    verify(providerTypeListRefreshEvent, times(1)).fire(new ProviderTypeListRefreshEvent(selectedProviders.get(0).getKey()));
}
Also used : ProviderTypeListRefreshEvent(org.guvnor.ala.ui.client.events.ProviderTypeListRefreshEvent) 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