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);
}
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);
}
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());
}
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);
}
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);
}
Aggregations