Search in sources :

Example 11 with Container

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

the class ContainerPresenterTest method init.

@Before
public void init() {
    runtimeManagementServiceCaller = new CallerMock<RuntimeManagementService>(runtimeManagementService);
    specManagementServiceCaller = new CallerMock<SpecManagementService>(specManagementService);
    doNothing().when(serverTemplateSelectedEvent).fire(any(ServerTemplateSelected.class));
    doNothing().when(notification).fire(any(NotificationEvent.class));
    when(containerStatusEmptyPresenter.getView()).thenReturn(containerStatusEmptyPresenterView);
    when(containerRemoteStatusPresenter.getView()).thenReturn(containerRemoteStatusPresenterView);
    presenter = spy(new ContainerPresenter(logger, view, containerRemoteStatusPresenter, containerStatusEmptyPresenter, containerProcessConfigPresenter, containerRulesConfigPresenter, runtimeManagementServiceCaller, specManagementServiceCaller, serverTemplateSelectedEvent, notification));
    releaseId = new ReleaseId("org.kie", "container", "1.0.0");
    serverTemplateKey = new ServerTemplateKey("serverTemplateKeyId", "serverTemplateKeyName");
    containerSpec = new ContainerSpec("containerId", "containerName", serverTemplateKey, releaseId, KieContainerStatus.STOPPED, new HashMap<Capability, ContainerConfig>());
    containerSpec.addConfig(Capability.PROCESS, new ProcessConfig());
    containerSpec.addConfig(Capability.RULE, new RuleConfig());
    containers = new ArrayList<Container>();
    containerSpecData = new ContainerSpecData(containerSpec, containers);
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ReleaseId(org.kie.server.api.model.ReleaseId) Container(org.kie.server.controller.api.model.runtime.Container) RuntimeManagementService(org.kie.workbench.common.screens.server.management.service.RuntimeManagementService) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) Before(org.junit.Before)

Example 12 with Container

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

Example 13 with Container

use of org.kie.server.controller.api.model.runtime.Container 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 14 with Container

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

the class AsyncKieServerInstanceManagerTest method createContainers.

protected List<Container> createContainers(KieContainerStatus status, List<Message> messages, int instances) {
    List<Container> containerList = new ArrayList<Container>();
    for (int i = 0; i < instances; i++) {
        Container container = new Container("c" + i, "name" + i, new ServerInstanceKey(serverTemplate.getId(), serverTemplate.getName(), serverTemplate.getId(), "http://testurl.com"), messages, null, "");
        container.setStatus(status);
        containerList.add(container);
    }
    return containerList;
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ArrayList(java.util.ArrayList) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey)

Example 15 with Container

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

the class RuntimeManagementServiceCDITest method getContainersByServerInstance_returnsEmptyList_whenInstanceWithIdDoesntExistInTemplate.

@Test
public void getContainersByServerInstance_returnsEmptyList_whenInstanceWithIdDoesntExistInTemplate() {
    final String templateId = "templateId";
    final String serverInstanceId = "serverInstanceId";
    KieServerTemplateStorage templateStorageMock = mock(KieServerTemplateStorage.class);
    when(templateStorageMock.load(eq(templateId))).thenReturn(new ServerTemplate(null, null, Collections.emptyList(), Collections.emptyMap(), Collections.emptyList(), Collections.emptyList()));
    // Setup tested service
    runtimeManagementService.setTemplateStorage(templateStorageMock);
    specManagementService.setTemplateStorage(templateStorageMock);
    // Tested method
    Collection<Container> containers = runtimeManagementServiceCDI.getContainersByServerInstance(templateId, serverInstanceId);
    assertThat(containers).as("List of containers should be empty, when Server template doesn't contain server instance id").isEmpty();
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) KieServerTemplateStorage(org.kie.server.controller.api.storage.KieServerTemplateStorage) Test(org.junit.Test)

Aggregations

Container (org.kie.server.controller.api.model.runtime.Container)21 Test (org.junit.Test)13 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)12 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)7 ReleaseId (org.kie.server.api.model.ReleaseId)6 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)5 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)5 ContainerCardPresenter (org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter)4 HashMap (java.util.HashMap)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Message (org.kie.server.api.model.Message)3 ServerInstance (org.kie.server.controller.api.model.runtime.ServerInstance)3 KieServerTemplateStorage (org.kie.server.controller.api.storage.KieServerTemplateStorage)3 ContainerSpecData (org.kie.workbench.common.screens.server.management.model.ContainerSpecData)3 ArrayList (java.util.ArrayList)2 ServerInstanceUpdated (org.kie.server.controller.api.model.events.ServerInstanceUpdated)2 Capability (org.kie.server.controller.api.model.spec.Capability)2 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)2 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)2 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)2