Search in sources :

Example 6 with ContainerCardPresenter

use of org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter in project kie-wb-common by kiegroup.

the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdated.

@Test
public void testOnServerInstanceUpdated() {
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    when(presenterProvider.get()).thenReturn(cardPresenter);
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container container = new Container("containerSpecId", "containerName", serverInstance, Collections.<Message>emptyList(), null, null);
    container.setStatus(KieContainerStatus.STARTED);
    final Container containerToBeRemoved = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
    containerToBeRemoved.setStatus(KieContainerStatus.STARTED);
    serverInstance.addContainer(container);
    presenter.setup(new ContainerSpec(), Arrays.asList(container, containerToBeRemoved));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    // One container updated,  one removed
    verify(cardPresenter).updateContent(serverInstance, container);
    verify(cardPresenter).delete();
    final ArgumentCaptor<Container> containerCaptor = ArgumentCaptor.forClass(Container.class);
    verify(cardPresenter, times(2)).setup(eq(container.getServerInstanceKey()), containerCaptor.capture());
    final List<Container> containers = containerCaptor.getAllValues();
    assertEquals(2, containers.size());
    assertEquals(container, containers.get(0));
    assertEquals(containerToBeRemoved, containers.get(1));
}
Also used : ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 7 with ContainerCardPresenter

use of org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter in project kie-wb-common by kiegroup.

the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdatedDuplicatedContainerName.

@Test
public void testOnServerInstanceUpdatedDuplicatedContainerName() {
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    when(presenterProvider.get()).thenReturn(cardPresenter);
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container container = new Container("containerSpecId", "containerName", serverInstance, Collections.<Message>emptyList(), null, null);
    container.setStatus(KieContainerStatus.STARTED);
    final Container container2 = new Container("containerSpecId2", "containerName", serverInstance, Collections.<Message>emptyList(), null, null);
    container2.setStatus(KieContainerStatus.STARTED);
    final Container containerToBeRemoved = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
    containerToBeRemoved.setStatus(KieContainerStatus.STARTED);
    serverInstance.addContainer(container);
    serverInstance.addContainer(container2);
    presenter.setup(new ContainerSpec(), Arrays.asList(container, container2, containerToBeRemoved));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    // One container updated,  one removed
    verify(cardPresenter).updateContent(serverInstance, container);
    verify(cardPresenter).updateContent(serverInstance, container2);
    verify(cardPresenter).delete();
    final ArgumentCaptor<Container> containerCaptor = ArgumentCaptor.forClass(Container.class);
    verify(cardPresenter, times(3)).setup(eq(container.getServerInstanceKey()), containerCaptor.capture());
    final List<Container> containers = containerCaptor.getAllValues();
    assertEquals(3, containers.size());
    assertEquals(container, containers.get(0));
    assertEquals(container2, containers.get(1));
    assertEquals(containerToBeRemoved, containers.get(2));
}
Also used : ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Aggregations

ContainerCardPresenter (org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter)7 Container (org.kie.server.controller.api.model.runtime.Container)5 Test (org.junit.Test)4 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)4 ServerInstanceUpdated (org.kie.server.controller.api.model.events.ServerInstanceUpdated)3 ServerInstance (org.kie.server.controller.api.model.runtime.ServerInstance)3 HashMap (java.util.HashMap)1 ReleaseId (org.kie.server.api.model.ReleaseId)1 ServerInstanceDeleted (org.kie.server.controller.api.model.events.ServerInstanceDeleted)1 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)1 Capability (org.kie.server.controller.api.model.spec.Capability)1 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)1 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)1