Search in sources :

Example 1 with Message

use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.

the class ContainerPresenter method resetReleaseIdForFailedContainers.

private void resetReleaseIdForFailedContainers(Collection<Container> containers, ContainerSpec containerSpec) {
    containers.forEach(container -> {
        if (KieContainerStatus.FAILED == container.getStatus() || container.getResolvedReleasedId() == null) {
            container.setResolvedReleasedId(containerSpec.getReleasedId());
            container.addMessage(new Message(Severity.ERROR, Collections.emptyList()));
        }
    });
}
Also used : Message(org.kie.server.api.model.Message)

Example 2 with Message

use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.

the class BodyPresenter method setup.

public void setup(final Collection<Message> messages) {
    checkNotNull("messages", messages);
    view.clear();
    if (messages.isEmpty()) {
        view.addNotification(setupNotification(null).getView());
    } else {
        for (final Message message : messages) {
            view.addNotification(setupNotification(message).getView());
        }
    }
}
Also used : Message(org.kie.server.api.model.Message)

Example 3 with Message

use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.

the class AsyncKieServerInstanceManagerTest method testContainerOperationFailure.

private void testContainerOperationFailure(ContainerRuntimeOperation operation) {
    List<Message> messages = new ArrayList<Message>();
    messages.add(new Message(Severity.ERROR, "No kmodule found"));
    returnedContainers.addAll(createContainers(KieContainerStatus.FAILED, messages, 1));
    switch(operation) {
        case STOP_CONTAINER:
            this.kieServerInstanceManager.stopContainer(serverTemplate, containerSpec);
            break;
        case START_CONTAINER:
            this.kieServerInstanceManager.startContainer(serverTemplate, containerSpec);
            break;
        case UPGRADE_CONTAINER:
            this.kieServerInstanceManager.upgradeContainer(serverTemplate, containerSpec);
            break;
        case SCAN:
            this.kieServerInstanceManager.scanNow(serverTemplate, containerSpec);
            break;
        case START_SCANNER:
            this.kieServerInstanceManager.startScanner(serverTemplate, containerSpec, 10);
            break;
        case STOP_SCANNER:
            this.kieServerInstanceManager.stopScanner(serverTemplate, containerSpec);
            break;
    }
    assertFalse(receivedEvents.isEmpty());
    assertEquals(1, receivedEvents.size());
    ContainerUpdateEvent updateEvent = receivedEvents.get(0);
    assertContainerUpdateEvent(updateEvent, ContainerRuntimeState.OFFLINE, 1);
}
Also used : Message(org.kie.server.api.model.Message) ArrayList(java.util.ArrayList) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)

Example 4 with Message

use of org.kie.server.api.model.Message 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 Message

use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.

the class ContainerCardPresenterTest method testSetupWithUnNamedContainer.

@Test
public void testSetupWithUnNamedContainer() {
    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", null, serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null);
    presenter.setup(container);
    verify(linkTitlePresenter).setup(eq(container.getContainerSpecId()), any(Command.class));
    verify(view).setCard(cardPresenterView);
    linkTitlePresenter.onSelect();
    final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerSpecId(), 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)

Aggregations

Message (org.kie.server.api.model.Message)15 Test (org.junit.Test)10 Container (org.kie.server.controller.api.model.runtime.Container)4 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)4 ArrayList (java.util.ArrayList)3 ReleaseId (org.kie.server.api.model.ReleaseId)3 CardPresenter (org.kie.workbench.common.screens.server.management.client.widget.card.CardPresenter)3 BodyPresenter (org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter)3 FooterPresenter (org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter)3 LinkTitlePresenter (org.kie.workbench.common.screens.server.management.client.widget.card.title.LinkTitlePresenter)3 ContainerUpdateEvent (org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)3 Command (org.uberfire.mvp.Command)3 ContainerSpecKey (org.kie.server.controller.api.model.spec.ContainerSpecKey)2 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)2 ContainerSpecSelected (org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected)2 InfoTitlePresenter (org.kie.workbench.common.screens.server.management.client.widget.card.title.InfoTitlePresenter)2 ServerInstance (org.kie.server.controller.api.model.runtime.ServerInstance)1 ServerInstanceSelected (org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected)1