Search in sources :

Example 31 with NotificationEvent

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

the class ProductionBuildAndDeployExecutorTest method testBuildAndDeploySingleServerTemplate.

@Test
public void testBuildAndDeploySingleServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
    serverTemplate.setMode(KieServerMode.PRODUCTION);
    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).saveContainerSpec(eq(serverTemplate.getId()), containerSpecArgumentCaptor.capture());
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verify(specManagementServiceMock).startContainer(containerSpecArgumentCaptor.capture());
    containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessfulAndContainerStarted(), 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 32 with NotificationEvent

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

the class NewWorkspaceProjectWizard method getSuccessCallback.

private RemoteCallback<WorkspaceProject> getSuccessCallback() {
    return new RemoteCallback<WorkspaceProject>() {

        @Override
        public void callback(final WorkspaceProject project) {
            NewWorkspaceProjectWizard.super.complete();
            invokeCallback(project);
            if (openEditor) {
                placeManager.goTo("ProjectSettings");
            }
            notificationEvent.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemCreatedSuccessfully()));
            busyIndicatorView.hideBusyIndicator();
        }
    };
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 33 with NotificationEvent

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

the class AssignmentListItemWidgetViewImpl method init.

@PostConstruct
public void init() {
    name.setRegExp(ALLOWED_CHARS, StunnerFormsClientFieldsConstants.CONSTANTS.Removed_invalid_characters_from_name(), StunnerFormsClientFieldsConstants.CONSTANTS.Invalid_character_in_name());
    name.addChangeHandler(event -> {
        String value = name.getText();
        String notifyMessage = null;
        if (isMultipleInstanceVariable(value)) {
            notifyMessage = StunnerFormsClientFieldsConstants.CONSTANTS.AssignmentNameAlreadyInUseAsMultipleInstanceInputOutputVariable(value);
        } else if (!allowDuplicateNames && isDuplicateName(value)) {
            notifyMessage = duplicateNameErrorMessage;
        }
        if (notifyMessage != null) {
            notification.fire(new NotificationEvent(notifyMessage, NotificationEvent.NotificationType.ERROR));
            name.setValue(EMPTY_VALUE);
            ValueChangeEvent.fire(name, EMPTY_VALUE);
        }
    });
    customDataType.setRegExp(StringUtils.ALPHA_NUM_UNDERSCORE_DOT_REGEXP, StunnerFormsClientFieldsConstants.CONSTANTS.Removed_invalid_characters_from_name(), StunnerFormsClientFieldsConstants.CONSTANTS.Invalid_character_in_name());
    customDataType.addKeyDownHandler(event -> {
        int iChar = event.getNativeKeyCode();
        if (iChar == ' ') {
            event.preventDefault();
        }
    });
    dataTypeComboBox.init(this, false, dataType, customDataType, false, true, CUSTOM_PROMPT, ENTER_TYPE_PROMPT);
    processVarComboBox.init(this, false, processVar, expression, true, true, EXPRESSION_PROMPT, ENTER_EXPRESSION_PROMPT);
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) PostConstruct(javax.annotation.PostConstruct)

Example 34 with NotificationEvent

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

the class RolesListItemWidgetViewImpl method handleValueChanged.

private void handleValueChanged() {
    final String currentRole = row.getModel().getKey();
    final String currentCardinality = row.getModel().getValue();
    if (StringUtils.isEmpty(currentRole)) {
        notification.fire(new NotificationEvent(EMPTY_ERROR_MESSAGE, NotificationEvent.NotificationType.ERROR));
        row.getModel().setKey(previousRole);
        return;
    }
    if (!allowDuplicateNames && isDuplicateName(currentRole)) {
        notification.fire(new NotificationEvent(DUPLICATE_NAME_ERROR_MESSAGE, NotificationEvent.NotificationType.ERROR));
        row.getModel().setKey(previousRole);
        return;
    }
    // skip in case not modified values
    if ((Objects.equals(previousRole, currentRole) && Objects.equals(previousCardinality, currentCardinality))) {
        return;
    }
    previousRole = currentRole;
    previousCardinality = currentCardinality;
    notifyModelChanged();
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 35 with NotificationEvent

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

the class AddProjectPopUpPresenterTest method createProjectCallbackBeforeProjectIndexedEventTest.

@Test
public void createProjectCallbackBeforeProjectIndexedEventTest() {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Path projectRootPath = mock(Path.class);
    doReturn(projectRootPath).when(project).getRootPath();
    doReturn(project).when(projectService).resolveProject(any(Path.class));
    doReturn(project).when(libraryService).createProject(any(), any(), any(), Mockito.<String>any());
    doReturn("test").when(view).getName();
    doReturn("description").when(view).getDescription();
    presenter.add();
    presenter.onProjectIndexingFinishedEvent(new IndexingFinishedEvent("kClusterId", projectRootPath));
    verify(view).setAddButtonEnabled(false);
    verify(view).showBusyIndicator(Mockito.<String>any());
    verify(view).setAddButtonEnabled(true);
    verify(view).hide();
    verify(notificationEvent).fire(any(NotificationEvent.class));
    verify(libraryPlaces).goToProject(project);
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) IndexingFinishedEvent(org.kie.workbench.common.services.refactoring.model.index.events.IndexingFinishedEvent) 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