Search in sources :

Example 56 with NotificationEvent

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

the class ContainerRulesConfigPresenterTest method testStopScannerError.

@Test
public void testStopScannerError() {
    doThrow(new RuntimeException()).when(ruleCapabilitiesService).stopScanner(eq(containerSpec));
    when(view.getStopScannerErrorMessage()).thenReturn("ERROR");
    presenter.setup(containerSpec, ruleConfig);
    presenter.stopScanner();
    verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
    verify(view).setStartScannerState(State.ENABLED);
    verify(view).setStopScannerState(State.DISABLED);
    verify(view).setScanNowState(State.ENABLED);
    verify(view).setUpgradeState(State.ENABLED);
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 57 with NotificationEvent

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

the class ContainerRulesConfigPresenterTest method testUpgrade.

@Test
public void testUpgrade() {
    final String version = "1.0";
    presenter.setup(containerSpec, ruleConfig);
    presenter.upgrade(version);
    verify(view).disableActions();
    final ArgumentCaptor<ReleaseId> releaseIdCaptor = ArgumentCaptor.forClass(ReleaseId.class);
    verify(ruleCapabilitiesService).upgradeContainer(eq(containerSpec), releaseIdCaptor.capture());
    assertEquals(version, releaseIdCaptor.getValue().getVersion());
    verify(view).setStartScannerState(State.ENABLED);
    verify(view).setStopScannerState(State.DISABLED);
    verify(view).setScanNowState(State.ENABLED);
    verify(view).setUpgradeState(State.ENABLED);
    verify(notification).fire(new NotificationEvent(SUCCESS_UPGRADE, NotificationEvent.NotificationType.SUCCESS));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Example 58 with NotificationEvent

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

the class ContainerRulesConfigPresenterTest method testScanNowError.

@Test
public void testScanNowError() {
    doThrow(new RuntimeException()).when(ruleCapabilitiesService).scanNow(eq(containerSpec));
    when(view.getScanNowErrorMessage()).thenReturn("ERROR");
    presenter.setup(containerSpec, ruleConfig);
    presenter.scanNow();
    verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
    verify(view).setStartScannerState(State.ENABLED);
    verify(view).setStopScannerState(State.DISABLED);
    verify(view).setScanNowState(State.ENABLED);
    verify(view).setUpgradeState(State.ENABLED);
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 59 with NotificationEvent

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

the class NewContainerWizardTest method testCompleteByCanNotFind.

@Test
public void testCompleteByCanNotFind() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
    final ContainerSpec containerSpec = new ContainerSpec();
    containerSpec.setId("containerSpecId");
    PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>();
    JarListPageRow jarListPageRow = new JarListPageRow();
    GAV gav = new GAV("test", "test", "1.0");
    containerSpec.setReleasedId(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()));
    jarListPageRow.setGav(new GAV("test1", "test1", "2.0"));
    jarListPageRow.setPath("test_path");
    response.setPageRowList(Arrays.asList(jarListPageRow));
    when(m2RepoService.listArtifacts(any())).thenReturn(response);
    when(newContainerFormPresenter.buildContainerSpec(eq(serverTemplate.getId()), anyMap())).thenReturn(containerSpec);
    when(newContainerFormPresenter.getServerTemplate()).thenReturn(serverTemplate);
    final String successMessage = "SUCCESS";
    doNothing().when(specManagementService).saveContainerSpec(anyString(), any(ContainerSpec.class));
    when(newContainerFormPresenterView.getNewContainerWizardSaveSuccess()).thenReturn(successMessage);
    newContainerWizard.setServerTemplate(serverTemplate);
    newContainerWizard.complete();
    verify(processConfigPagePresenter).buildProcessConfig();
    verify(newContainerFormPresenter).buildContainerSpec(eq(serverTemplate.getId()), anyMap());
    ArgumentCaptor<Command> captureCommand = ArgumentCaptor.forClass(Command.class);
    verify(confirmPopup).show(any(), any(), any(), captureCommand.capture());
    captureCommand.getValue().execute();
    final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
    verify(notification).fire(eventCaptor.capture());
    final NotificationEvent event = eventCaptor.getValue();
    assertEquals(successMessage, event.getNotification());
    assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType());
    final ArgumentCaptor<ServerTemplateSelected> serverTemplateEventCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
    verify(serverTemplateSelectedEvent).fire(serverTemplateEventCaptor.capture());
    final ServerTemplateSelected serverEvent = serverTemplateEventCaptor.getValue();
    assertEquals(serverTemplate, serverEvent.getServerTemplateKey());
    assertEquals(containerSpec.getId(), serverEvent.getContainerId());
    verifyClear();
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) JarListPageRow(org.guvnor.m2repo.model.JarListPageRow) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ReleaseId(org.kie.server.api.model.ReleaseId) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Command(org.uberfire.mvp.Command) PageResponse(org.uberfire.paging.PageResponse) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 60 with NotificationEvent

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

the class NewContainerWizardTest method testPageSelectedCanNotFind.

@Test
public void testPageSelectedCanNotFind() {
    PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>();
    JarListPageRow jarListPageRow = new JarListPageRow();
    GAV gav = new GAV("test", "test", "");
    jarListPageRow.setGav(new GAV("test1", "test1", "1.0"));
    jarListPageRow.setPath("test_path");
    response.setPageRowList(Arrays.asList(jarListPageRow));
    when(m2RepoService.listArtifacts(any())).thenReturn(response);
    when(newContainerFormPresenter.getCurrentGAV()).thenReturn(gav);
    final String gavNotFind = "NOTFIND";
    when(newContainerFormPresenterView.getNewContainerGAVNotExist(any())).thenReturn(gavNotFind);
    newContainerWizard.pages.add(mock(WizardPage.class));
    newContainerWizard.pages.add(mock(WizardPage.class));
    newContainerWizard.pageSelected(1);
    final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
    verify(notification).fire(eventCaptor.capture());
    final NotificationEvent event = eventCaptor.getValue();
    assertEquals(gavNotFind, event.getNotification());
}
Also used : WizardPage(org.uberfire.ext.widgets.core.client.wizards.WizardPage) JarListPageRow(org.guvnor.m2repo.model.JarListPageRow) PageResponse(org.uberfire.paging.PageResponse) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) GAV(org.guvnor.common.services.project.model.GAV) 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