Search in sources :

Example 11 with ServerTemplateSelected

use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.

the class NewContainerWizardTest method testComplete.

@Test
public void testComplete() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
    final ContainerSpec containerSpec = new ContainerSpec();
    containerSpec.setId("containerSpecId");
    when(newContainerFormPresenter.buildContainerSpec(eq(serverTemplate.getId()), anyMap())).thenReturn(containerSpec);
    when(newContainerFormPresenter.getServerTemplate()).thenReturn(serverTemplate);
    final String successMessage = "SUCCESS";
    when(newContainerFormPresenterView.getNewContainerWizardSaveSuccess()).thenReturn(successMessage);
    newContainerWizard.setServerTemplate(serverTemplate);
    newContainerWizard.complete();
    verify(processConfigPagePresenter).buildProcessConfig();
    verify(newContainerFormPresenter).buildContainerSpec(eq(serverTemplate.getId()), anyMap());
    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();
    doThrow(new RuntimeException()).when(specManagementService).saveContainerSpec(anyString(), any(ContainerSpec.class));
    final String errorMessage = "ERROR";
    when(newContainerFormPresenterView.getNewContainerWizardSaveError()).thenReturn(errorMessage);
    newContainerWizard.complete();
    verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
    verify(newContainerWizard).pageSelected(0);
    verify(newContainerWizard).start();
    verify(newContainerFormPresenter).initialise();
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Aggregations

ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)11 Test (org.junit.Test)9 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)8 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)5 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)3 ServerTemplateKeyList (org.kie.server.controller.api.model.spec.ServerTemplateKeyList)3 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 ServerTemplatePresenter (org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 ServerInstanceDeleted (org.kie.server.controller.api.model.events.ServerInstanceDeleted)1 ServerTemplateDeleted (org.kie.server.controller.api.model.events.ServerTemplateDeleted)1 ServerTemplateUpdated (org.kie.server.controller.api.model.events.ServerTemplateUpdated)1 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)1 Capability (org.kie.server.controller.api.model.spec.Capability)1 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)1 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)1 ServerContainerEmptyPresenter (org.kie.workbench.common.screens.server.management.client.container.empty.ServerContainerEmptyPresenter)1