Search in sources :

Example 11 with ServerInstanceKey

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

the class ServerTemplatePresenter method setup.

public void setup(final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec) {
    view.clear();
    this.serverTemplate = serverTemplate;
    view.setTemplate(serverTemplate.getId(), serverTemplate.getName());
    view.setProcessCapability(serverTemplate.getCapabilities().contains(Capability.PROCESS.toString()));
    view.setRulesCapability(serverTemplate.getCapabilities().contains(Capability.RULE.toString()));
    view.setPlanningCapability(serverTemplate.getCapabilities().contains(Capability.PLANNING.toString()));
    if (firstContainerSpec != null) {
        addContainer(firstContainerSpec);
        for (final ContainerSpec containerSpec : serverTemplate.getContainersSpec()) {
            if (!containerSpec.getId().equals(firstContainerSpec.getId())) {
                addContainer(containerSpec);
            }
        }
        containerSpecSelectedEvent.fire(new ContainerSpecSelected(firstContainerSpec));
    }
    for (final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys()) {
        addServerInstance(serverInstanceKey);
    }
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey)

Example 12 with ServerInstanceKey

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

the class ServerManagementBrowserPresenterTest method testOnDelete.

@Test
public void testOnDelete() {
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverInstanceKeyId", "serverName", "serverInstanceId", "url");
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    serverTemplate.addServerInstance(serverInstanceKey);
    when(serverTemplatePresenter.getCurrentServerTemplate()).thenReturn(serverTemplate);
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
    final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList(serverTemplateKey);
    when(specManagementService.listServerTemplateKeys()).thenReturn(new ServerTemplateKeyList(serverTemplateKeys));
    presenter.onDelete(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId()));
    verify(navigationPresenter).setup(serverTemplateKey, serverTemplateKeys);
    final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
    verify(serverTemplateSelectedEvent).fire(templateSelectedCaptor.capture());
    assertEquals(serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerTemplateKeyList(org.kie.server.controller.api.model.spec.ServerTemplateKeyList) Test(org.junit.Test)

Example 13 with ServerInstanceKey

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

the class ServerManagementBrowserPresenterTest method testOnContainerUpdateWarn.

@Test
public void testOnContainerUpdateWarn() {
    when(view.getWarnMessage(ClientContainerRuntimeOperation.START_CONTAINER, 2)).thenReturn("Warn");
    presenter.onContainerUpdate(new ContainerUpdateEvent(mock(ServerTemplateKey.class), mock(ContainerSpec.class), new ArrayList<ServerInstanceKey>() {

        {
            add(mock(ServerInstanceKey.class));
            add(mock(ServerInstanceKey.class));
        }
    }, ContainerRuntimeState.PARTIAL_ONLINE, ContainerRuntimeOperation.START_CONTAINER));
    verify(notification).fire(new NotificationEvent("Warn", NotificationEvent.NotificationType.WARNING));
}
Also used : ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Example 14 with ServerInstanceKey

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

the class ContainerPresenterTest method testLoadContainers.

@Test
public void testLoadContainers() {
    final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null);
    containerSpecData.getContainers().add(container);
    presenter.loadContainers(containerSpecData);
    verifyLoad(true, 1);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 15 with ServerInstanceKey

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

the class ContainerRemoteStatusPresenterTest method testOnDelete.

@Test
public void testOnDelete() {
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    when(presenterProvider.get()).thenReturn(cardPresenter);
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
    final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.<Message>emptyList(), null, null);
    container.setStatus(KieContainerStatus.STARTED);
    presenter.setup(new ContainerSpec(), Collections.singletonList(container));
    verify(view).clear();
    verify(cardPresenter).setup(container.getServerInstanceKey(), container);
    verify(view).addCard(any(IsWidget.class));
    presenter.onDelete(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId()));
    verify(cardPresenter).delete();
    presenter.onDelete(new ServerInstanceDeleted("randomKey"));
    verify(cardPresenter).delete();
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Aggregations

ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)32 Test (org.junit.Test)28 Container (org.kie.server.controller.api.model.runtime.Container)12 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)11 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)11 ReleaseId (org.kie.server.api.model.ReleaseId)7 ServerInstanceSelected (org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected)7 ArrayList (java.util.ArrayList)5 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)5 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)5 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)4 ContainerUpdateEvent (org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)4 Path (org.uberfire.java.nio.file.Path)4 Message (org.kie.server.api.model.Message)3 ServerInstanceDeleted (org.kie.server.controller.api.model.events.ServerInstanceDeleted)3 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)3 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)3 ContainerSpecSelected (org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected)3 Command (org.uberfire.mvp.Command)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2