Search in sources :

Example 1 with BodyPresenter

use of org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter 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 2 with BodyPresenter

use of org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter 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)

Example 3 with BodyPresenter

use of org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter in project kie-wb-common by kiegroup.

the class ContainerCardPresenterTest method testSetup.

@Test
public void testSetup() {
    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(serverInstanceKey, container);
    verify(linkTitlePresenter).setup(eq(serverInstanceKey.getServerName()), any(Command.class));
    verify(bodyPresenter).setup(Arrays.asList(message));
    verify(footerPresenter).setup(container.getUrl(), resolvedReleasedId.getVersion());
    verify(cardPresenter).addTitle(linkTitlePresenter);
    verify(cardPresenter).addBody(bodyPresenter);
    verify(cardPresenter).addFooter(footerPresenter);
    verify(view).setCard(cardPresenterView);
    linkTitlePresenter.onSelect();
    verify(remoteServerSelectedEvent).fire(eq(new ServerInstanceSelected(serverInstanceKey)));
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) Message(org.kie.server.api.model.Message) Command(org.uberfire.mvp.Command) FooterPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter) CardPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.CardPresenter) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ReleaseId(org.kie.server.api.model.ReleaseId) LinkTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.LinkTitlePresenter) ServerInstanceSelected(org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected) BodyPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter) Test(org.junit.Test)

Example 4 with BodyPresenter

use of org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter in project kie-wb-common by kiegroup.

the class CardPresenterTest method testAddBody.

@Test
public void testAddBody() {
    BodyPresenter bodyPresenter = mock(BodyPresenter.class);
    presenter.addBody(bodyPresenter);
    verify(bodyPresenter).getView();
    verify(view).add(bodyPresenter.getView());
}
Also used : BodyPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter) Test(org.junit.Test)

Example 5 with BodyPresenter

use of org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter in project kie-wb-common by kiegroup.

the class ContainerCardPresenter method setup.

public void setup(final Container container) {
    final LinkTitlePresenter linkTitlePresenter = presenterProvider.select(LinkTitlePresenter.class).get();
    linkTitlePresenter.setup(container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() {

        @Override
        public void execute() {
            containerSpecSelectedEvent.fire(new ContainerSpecSelected(buildContainerSpecKey(container)));
        }
    });
    final InfoTitlePresenter infoTitlePresenter = presenterProvider.select(InfoTitlePresenter.class).get();
    infoTitlePresenter.setup(container.getResolvedReleasedId());
    final BodyPresenter bodyPresenter = presenterProvider.select(BodyPresenter.class).get();
    bodyPresenter.setup(container.getMessages());
    final FooterPresenter footerPresenter = presenterProvider.select(FooterPresenter.class).get();
    footerPresenter.setup(container.getUrl(), container.getResolvedReleasedId().getVersion());
    CardPresenter card = presenterProvider.select(CardPresenter.class).get();
    card.addTitle(linkTitlePresenter);
    card.addTitle(infoTitlePresenter);
    card.addBody(bodyPresenter);
    card.addFooter(footerPresenter);
    view.setCard(card.getView());
}
Also used : InfoTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.InfoTitlePresenter) Command(org.uberfire.mvp.Command) FooterPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter) CardPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.CardPresenter) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) 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)

Aggregations

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