Search in sources :

Example 16 with Container

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

the class ServerTemplateVFSStorageTest method createServerTemplateWithContainer.

/*
     * helper method to setup template container and container spec
     */
protected void createServerTemplateWithContainer() {
    serverTemplate = new ServerTemplate();
    serverTemplate.setName("test server");
    serverTemplate.setId(UUID.randomUUID().toString());
    Map<Capability, ContainerConfig> configs = new HashMap<Capability, ContainerConfig>();
    ruleConfig = new RuleConfig();
    ruleConfig.setPollInterval(1000l);
    ruleConfig.setScannerStatus(KieScannerStatus.STARTED);
    configs.put(Capability.RULE, ruleConfig);
    processConfig = new ProcessConfig();
    processConfig.setKBase("defaultKieBase");
    processConfig.setKSession("defaultKieSession");
    processConfig.setMergeMode("MERGE_COLLECTION");
    processConfig.setRuntimeStrategy("PER_PROCESS_INSTANCE");
    configs.put(Capability.PROCESS, processConfig);
    containerSpec = new ContainerSpec();
    containerSpec.setId("test container");
    containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
    containerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "1.0"));
    containerSpec.setStatus(KieContainerStatus.STOPPED);
    containerSpec.setConfigs(configs);
    serverTemplate.addContainerSpec(containerSpec);
    container = new Container();
    container.setServerInstanceId(serverTemplate.getId());
    container.setServerTemplateId(serverTemplate.getId());
    container.setResolvedReleasedId(containerSpec.getReleasedId());
    container.setContainerName(containerSpec.getContainerName());
    container.setContainerSpecId(containerSpec.getId());
    container.setUrl("http://fake.server.net/kie-server");
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Container(org.kie.server.controller.api.model.runtime.Container) Capability(org.kie.server.controller.api.model.spec.Capability) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) ReleaseId(org.kie.server.api.model.ReleaseId)

Example 17 with Container

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

the class ContainerPresenterTest method testLoadContainersNonStoped.

@Test
public void testLoadContainersNonStoped() {
    final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null);
    container.setStatus(KieContainerStatus.STARTED);
    containerSpecData.getContainers().add(container);
    presenter.loadContainers(containerSpecData);
    verifyLoad(false, 1);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 18 with Container

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

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

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

the class RemoteStatusPresenterTest method testSetup.

@Test
public void testSetup() {
    final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null);
    presenter.setup(Collections.singletonList(container));
    verify(containerCardPresenter).setup(container);
    verify(view).addCard(any(Widget.class));
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) Widget(com.google.gwt.user.client.ui.Widget) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) 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