Search in sources :

Example 31 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec 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)

Example 32 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class NewContainerFormPresenterTest method testNewContainerStarted.

@Test
public void testNewContainerStarted() {
    final String path = "org:kie:1.0";
    final GAV gav = new GAV(path);
    when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav);
    when(view.getContainerName()).thenReturn("containerName");
    when(view.getContainerAlias()).thenReturn("containerAlias");
    when(view.getGroupId()).thenReturn(gav.getGroupId());
    when(view.getArtifactId()).thenReturn(gav.getArtifactId());
    when(view.getVersion()).thenReturn(gav.getVersion());
    when(view.isStartContainer()).thenReturn(true);
    presenter.asWidget();
    final ContainerSpec containerSpec = presenter.buildContainerSpec("templateId", Collections.<Capability, ContainerConfig>emptyMap());
    assertEquals(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()), containerSpec.getReleasedId());
    assertEquals(KieContainerStatus.STARTED, containerSpec.getStatus());
    assertEquals("containerAlias", containerSpec.getContainerName());
    assertEquals("containerName", containerSpec.getId());
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Matchers.anyString(org.mockito.Matchers.anyString) ReleaseId(org.kie.server.api.model.ReleaseId) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 33 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class NewContainerFormPresenterTest method testOnDependencyPathSelectedEvent.

@Test
public void testOnDependencyPathSelectedEvent() {
    final String path = "org:kie:1.0";
    final GAV gav = new GAV(path);
    when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav);
    when(view.getContainerName()).thenReturn("containerName");
    when(view.getContainerAlias()).thenReturn("containerAlias");
    when(view.getGroupId()).thenReturn(gav.getGroupId());
    when(view.getArtifactId()).thenReturn(gav.getArtifactId());
    when(view.getVersion()).thenReturn(gav.getVersion());
    presenter.asWidget();
    presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path));
    verify(m2RepoService).loadGAVFromJar(path);
    verify(view).setGroupId(gav.getGroupId());
    verify(view).setArtifactId(gav.getArtifactId());
    verify(view).setVersion(gav.getVersion());
    verify(wizardPageStatusChangeEvent).fire(any(WizardPageStatusChangeEvent.class));
    final ContainerSpec containerSpec = presenter.buildContainerSpec("templateId", Collections.<Capability, ContainerConfig>emptyMap());
    assertEquals(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()), containerSpec.getReleasedId());
    assertEquals(KieContainerStatus.STOPPED, containerSpec.getStatus());
    assertEquals("containerAlias", containerSpec.getContainerName());
    assertEquals("containerName", containerSpec.getId());
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Matchers.anyString(org.mockito.Matchers.anyString) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) ReleaseId(org.kie.server.api.model.ReleaseId) GAV(org.guvnor.common.services.project.model.GAV) DependencyPathSelectedEvent(org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent) Test(org.junit.Test)

Aggregations

ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)33 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)22 Test (org.junit.Test)20 ReleaseId (org.kie.server.api.model.ReleaseId)13 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)10 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)8 Container (org.kie.server.controller.api.model.runtime.Container)7 Capability (org.kie.server.controller.api.model.spec.Capability)7 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)7 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)6 HashMap (java.util.HashMap)5 Path (org.uberfire.java.nio.file.Path)5 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)4 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GAV (org.guvnor.common.services.project.model.GAV)3 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)3