Search in sources :

Example 1 with ServerInstance

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

the class ServerTemplatePresenterTest method testOnServerInstanceUpdatedWithoutCurrentServer.

@Test
public void testOnServerInstanceUpdatedWithoutCurrentServer() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    final ServerInstance serverInstance = new ServerInstance(serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    verify(view, never()).addServerInstance(anyString(), anyString(), anyString(), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 2 with ServerInstance

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

the class RemotePresenterTest method testOnInstanceUpdateWithoutSelect.

@Test
public void testOnInstanceUpdateWithoutSelect() {
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    presenter.onInstanceUpdate(new ServerInstanceUpdated(serverInstance));
    verify(view, never()).clear();
    verify(view, never()).setServerName(anyString());
    verify(view, never()).setServerURL(anyString());
    verify(view, never()).setEmptyView(any(RemoteEmptyView.class));
}
Also used : ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) RemoteEmptyView(org.kie.workbench.common.screens.server.management.client.remote.empty.RemoteEmptyView) Test(org.junit.Test)

Example 3 with ServerInstance

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

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

the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdatedNewInstance.

@Test
public void testOnServerInstanceUpdatedNewInstance() {
    presenter = spy(new ContainerRemoteStatusPresenter(logger, view, presenterProvider));
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    final ContainerCardPresenter cardPresenter2 = mock(ContainerCardPresenter.class);
    when(cardPresenter2.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    final ContainerCardPresenter cardPresenter3 = mock(ContainerCardPresenter.class);
    when(cardPresenter3.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    doReturn(cardPresenter).doReturn(cardPresenter2).doReturn(cardPresenter3).when(presenterProvider).get();
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverInstanceId", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container existingContainer = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
    existingContainer.setStatus(KieContainerStatus.STARTED);
    final ServerInstance newServerInstance = new ServerInstance("templateId", "newserverInstanceId", "newserverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container newContainer = new Container("containerSpecId", "containerName", newServerInstance, Collections.<Message>emptyList(), null, null);
    newContainer.setStatus(KieContainerStatus.STARTED);
    newServerInstance.addContainer(newContainer);
    presenter.setup(new ContainerSpec("containerSpecId", "containerName", new ServerTemplateKey("templateId", "templateId"), new ReleaseId(), KieContainerStatus.STARTED, Collections.<Capability, ContainerConfig>emptyMap()), Arrays.asList(existingContainer));
    verify(cardPresenter).setup(toKey(serverInstance), existingContainer);
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
    // One container added
    verify(cardPresenter2).setup(toKey(newServerInstance), newContainer);
    final Container newContainer2 = new Container("containerSpecId", "containerNameX", newServerInstance, Collections.<Message>emptyList(), null, null);
    newContainer2.setStatus(KieContainerStatus.STARTED);
    newServerInstance.addContainer(newContainer2);
    // One new container added to existing server
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
    verify(cardPresenter3).setup(newContainer2.getServerInstanceKey(), newContainer2);
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Capability(org.kie.server.controller.api.model.spec.Capability) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 5 with ServerInstance

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

the class ServerTemplatePresenterTest method testOnServerInstanceUpdated.

@Test
public void testOnServerInstanceUpdated() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    presenter.setup(serverTemplate, null);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    final ServerInstance serverInstance = new ServerInstance(serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    verify(view).addServerInstance(eq(serverInstance.getServerTemplateId()), eq(serverInstance.getServerInstanceId()), eq(serverInstance.getServerName()), any(Command.class));
    presenter.onServerInstanceDeleted(new ServerInstanceDeleted(serverInstance.getServerInstanceId()));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    verify(view, times(2)).addServerInstance(eq(serverInstance.getServerTemplateId()), eq(serverInstance.getServerInstanceId()), eq(serverInstance.getServerName()), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ServerInstance (org.kie.server.controller.api.model.runtime.ServerInstance)8 ServerInstanceUpdated (org.kie.server.controller.api.model.events.ServerInstanceUpdated)7 Container (org.kie.server.controller.api.model.runtime.Container)3 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)2 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)2 ContainerCardPresenter (org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter)2 ServerInstanceSelected (org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected)2 Command (org.uberfire.mvp.Command)2 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)2 Message (org.kie.server.api.model.Message)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 RemoteEmptyView (org.kie.workbench.common.screens.server.management.client.remote.empty.RemoteEmptyView)1