Search in sources :

Example 1 with ServerInstanceKey

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

the class ServerTemplatePresenterTest method testOnServerInstanceSelect.

@Test
public void testOnServerInstanceSelect() {
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverInstanceKeyId", "serverName", "serverInstanceId", "url");
    presenter.onServerInstanceSelect(new ServerInstanceSelected(serverInstanceKey));
    verify(view).selectServerInstance(serverInstanceKey.getServerTemplateId(), serverInstanceKey.getServerInstanceId());
}
Also used : ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerInstanceSelected(org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected) Test(org.junit.Test)

Example 2 with ServerInstanceKey

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

the class RemotePresenterTest method testRemove.

@Test
public void testRemove() {
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
    presenter.onSelect(new ServerInstanceSelected(serverInstanceKey));
    presenter.remove();
    verify(specManagementService).deleteServerInstance(serverInstanceKey);
    verify(notification).fire(any(NotificationEvent.class));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerInstanceSelected(org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected) Test(org.junit.Test)

Example 3 with ServerInstanceKey

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

the class RemotePresenterTest method testSelectAndRefresh.

@Test
public void testSelectAndRefresh() {
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
    final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.<Message>emptyList(), null, null);
    final List<Container> containers = Collections.singletonList(container);
    when(runtimeManagementService.getContainersByServerInstance(serverInstanceKey.getServerTemplateId(), serverInstanceKey.getServerInstanceId())).thenReturn(containers);
    presenter.onSelect(new ServerInstanceSelected(serverInstanceKey));
    verify(view).clear();
    verify(view).setServerName(serverInstanceKey.getServerName());
    verify(view).setServerURL(serverInstanceKey.getUrl());
    verify(remoteStatusPresenter).setup(containers);
    verify(view).setStatusPresenter(remoteStatusPresenter.getView());
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerInstanceSelected(org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected) Test(org.junit.Test)

Example 4 with ServerInstanceKey

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

the class ContainerCardPresenterTest method testSetup.

@Test
public void testSetup() {
    final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class);
    when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter);
    final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class)));
    when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter);
    final BodyPresenter bodyPresenter = mock(BodyPresenter.class);
    when(bodyPresenterProvider.get()).thenReturn(bodyPresenter);
    final FooterPresenter footerPresenter = mock(FooterPresenter.class);
    when(footerPresenterProvider.get()).thenReturn(footerPresenter);
    final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class);
    final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView));
    when(cardPresenterProvider.get()).thenReturn(cardPresenter);
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
    final Message message = new Message(Severity.INFO, "testMessage");
    final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0");
    final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null);
    presenter.setup(container);
    verify(linkTitlePresenter).setup(eq(container.getContainerName()), any(Command.class));
    verify(infoTitlePresenter).setup(container.getResolvedReleasedId());
    verify(bodyPresenter).setup(Arrays.asList(message));
    verify(footerPresenter).setup(container.getUrl(), resolvedReleasedId.getVersion());
    verify(cardPresenter).addTitle(linkTitlePresenter);
    verify(cardPresenter).addTitle(infoTitlePresenter);
    verify(cardPresenter).addBody(bodyPresenter);
    verify(cardPresenter).addFooter(footerPresenter);
    verify(view).setCard(cardPresenterView);
    linkTitlePresenter.onSelect();
    final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), ""));
    verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey)));
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Message(org.kie.server.api.model.Message) FooterPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter) ReleaseId(org.kie.server.api.model.ReleaseId) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) InfoTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.InfoTitlePresenter) Container(org.kie.server.controller.api.model.runtime.Container) Command(org.uberfire.mvp.Command) CardPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.CardPresenter) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) LinkTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.LinkTitlePresenter) BodyPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter) Test(org.junit.Test)

Example 5 with ServerInstanceKey

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

the class AsyncKieServerInstanceManager method produceContainerUpdateEvent.

protected void produceContainerUpdateEvent(ServerTemplate serverTemplate, ContainerSpec containerSpec, List<Container> containers, ContainerRuntimeOperation containerRuntimeOperation) {
    List<ServerInstanceKey> failedServerInstances = new ArrayList<ServerInstanceKey>();
    for (Container container : containers) {
        if (hasIssues(container)) {
            failedServerInstances.add(container.getServerInstanceKey());
        }
    }
    ContainerRuntimeState containerRuntimeState = ContainerRuntimeState.ONLINE;
    if (failedServerInstances.size() == containers.size()) {
        containerRuntimeState = ContainerRuntimeState.OFFLINE;
    } else if (!failedServerInstances.isEmpty()) {
        containerRuntimeState = ContainerRuntimeState.PARTIAL_ONLINE;
    }
    ContainerUpdateEvent updateEvent = new ContainerUpdateEvent(serverTemplate, containerSpec, failedServerInstances, containerRuntimeState, containerRuntimeOperation);
    containerUpdateEvent.fire(updateEvent);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ContainerRuntimeState(org.kie.workbench.common.screens.server.management.model.ContainerRuntimeState) ArrayList(java.util.ArrayList) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)

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