Search in sources :

Example 1 with ContainerSpecData

use of org.kie.workbench.common.screens.server.management.model.ContainerSpecData in project kie-wb-common by kiegroup.

the class RuntimeManagementServiceCDI method getContainersByContainerSpec.

@Override
public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) {
    final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId);
    final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId);
    final ServerInstanceKeyList instances = service.getServerInstances(serverTemplateId);
    if (instances.getServerInstanceKeys() == null) {
        return null;
    }
    final List<Container> containers = Arrays.stream(instances.getServerInstanceKeys()).flatMap(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers()).stream()).filter(container -> containerSpecId.equals(container.getContainerSpecId())).collect(Collectors.toList());
    return new ContainerSpecData(containerSpec, containers);
}
Also used : Arrays(java.util.Arrays) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Collection(java.util.Collection) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) List(java.util.List) Service(org.jboss.errai.bus.server.annotations.Service) Container(org.kie.server.controller.api.model.runtime.Container) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) Any(javax.enterprise.inject.Any) ServerInstanceKeyList(org.kie.server.controller.api.model.runtime.ServerInstanceKeyList) Collections(java.util.Collections) RuntimeManagementService(org.kie.workbench.common.screens.server.management.service.RuntimeManagementService) Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKeyList(org.kie.server.controller.api.model.runtime.ServerInstanceKeyList) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData)

Example 2 with ContainerSpecData

use of org.kie.workbench.common.screens.server.management.model.ContainerSpecData in project kie-wb-common by kiegroup.

the class RuntimeManagementServiceCDITest method getContainersByContainerSpec_returnsContainerSpecData.

@Test
public void getContainersByContainerSpec_returnsContainerSpecData() {
    final String templateId = "templateId", templateName = "templateName", serverInstanceId = "serverInstanceId", containerName = "containerName1", group = "g1", artifact = "a1", version = "1", containerSpecId = String.join(":", group, artifact, version);
    final ReleaseId releaseId = new ReleaseId(group, artifact, version);
    ServerInstanceKey serverInstanceKey = new ServerInstanceKey(templateId, null, serverInstanceId, null);
    Container container = new Container(containerSpecId, containerName, serverInstanceKey, Collections.emptyList(), releaseId, null);
    ContainerSpec containerSpec = new ContainerSpec(containerSpecId, containerName, new ServerTemplateKey(templateId, templateName), releaseId, KieContainerStatus.STARTED, Collections.emptyMap());
    ServerTemplate serverTemplate = new ServerTemplate(templateId, templateName, Collections.emptyList(), Collections.emptyMap(), Collections.singletonList(containerSpec), Collections.singletonList(serverInstanceKey));
    final List<Container> containersInServerInstance = Collections.singletonList(container);
    // Setup mocks
    KieServerTemplateStorage templateStorageMock = createMockStorageWithOneTemplate(serverTemplate);
    KieServerInstanceManager instanceMangerMock = mock(KieServerInstanceManager.class);
    when(instanceMangerMock.getContainers(serverInstanceKey)).thenReturn(containersInServerInstance);
    // Setup tested object
    runtimeManagementService.setTemplateStorage(templateStorageMock);
    runtimeManagementService.setKieServerInstanceManager(instanceMangerMock);
    specManagementService.setTemplateStorage(templateStorageMock);
    specManagementService.setKieServerInstanceManager(instanceMangerMock);
    // Tested method
    ContainerSpecData containerSpecData = runtimeManagementServiceCDI.getContainersByContainerSpec(templateId, containerSpecId);
    assertThat(containerSpecData.getContainers()).contains(container);
    assertThat(containerSpecData.getContainerSpec()).isEqualTo(containerSpec);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerInstanceManager(org.kie.server.controller.impl.KieServerInstanceManager) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) KieServerTemplateStorage(org.kie.server.controller.api.storage.KieServerTemplateStorage) Test(org.junit.Test)

Example 3 with ContainerSpecData

use of org.kie.workbench.common.screens.server.management.model.ContainerSpecData in project kie-wb-common by kiegroup.

the class ContainerPresenterTest method testLoadWhenRuntimeManagementServiceReturnsInvalidData.

// Test fix for GUVNOR-3579
@Test
public void testLoadWhenRuntimeManagementServiceReturnsInvalidData() {
    ContainerSpecData badData = new ContainerSpecData(null, null);
    when(runtimeManagementService.getContainersByContainerSpec(anyObject(), anyObject())).thenReturn(badData);
    ContainerSpecKey lookupKey = new ContainerSpecKey("dummyId", "dummyName", new ServerTemplateKey("keyId", "keyName"));
    // Doesn't throw NPE when ContainerSpecData contain nulls
    presenter.load(lookupKey);
    verify(view, never()).setContainerName(anyString());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) Test(org.junit.Test)

Example 4 with ContainerSpecData

use of org.kie.workbench.common.screens.server.management.model.ContainerSpecData 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 5 with ContainerSpecData

use of org.kie.workbench.common.screens.server.management.model.ContainerSpecData in project kie-wb-common by kiegroup.

the class EmbeddedNotificationService method notify.

@Override
public void notify(final ServerTemplate serverTemplate, final ContainerSpec containerSpec, final List<Container> containers) {
    ContainerSpecData containerSpecData = new ContainerSpecData(containerSpec, containers);
    containerSpecDataEvent.fire(containerSpecData);
}
Also used : ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData)

Aggregations

ContainerSpecData (org.kie.workbench.common.screens.server.management.model.ContainerSpecData)6 Container (org.kie.server.controller.api.model.runtime.Container)3 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)3 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)3 Test (org.junit.Test)2 ReleaseId (org.kie.server.api.model.ReleaseId)2 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)2 RuntimeManagementService (org.kie.workbench.common.screens.server.management.service.RuntimeManagementService)2 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Any (javax.enterprise.inject.Any)1 Inject (javax.inject.Inject)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Service (org.jboss.errai.bus.server.annotations.Service)1 Before (org.junit.Before)1