use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class RemotePresenterTest method testSelectAndRefresh.
@Test
public void testSelectAndRefresh() {
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.<Message>emptyList(), null, null);
final List<Container> containers = Collections.singletonList(container);
when(runtimeManagementService.getContainersByServerInstance(serverInstanceKey.getServerTemplateId(), serverInstanceKey.getServerInstanceId())).thenReturn(containers);
presenter.onSelect(new ServerInstanceSelected(serverInstanceKey));
verify(view).clear();
verify(view).setServerName(serverInstanceKey.getServerName());
verify(view).setServerURL(serverInstanceKey.getUrl());
verify(remoteStatusPresenter).setup(containers);
verify(view).setStatusPresenter(remoteStatusPresenter.getView());
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class ContainerCardPresenterTest method testSetup.
@Test
public void testSetup() {
final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class);
when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter);
final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class)));
when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter);
final BodyPresenter bodyPresenter = mock(BodyPresenter.class);
when(bodyPresenterProvider.get()).thenReturn(bodyPresenter);
final FooterPresenter footerPresenter = mock(FooterPresenter.class);
when(footerPresenterProvider.get()).thenReturn(footerPresenter);
final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class);
final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView));
when(cardPresenterProvider.get()).thenReturn(cardPresenter);
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
final Message message = new Message(Severity.INFO, "testMessage");
final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0");
final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null);
presenter.setup(container);
verify(linkTitlePresenter).setup(eq(container.getContainerName()), any(Command.class));
verify(infoTitlePresenter).setup(container.getResolvedReleasedId());
verify(bodyPresenter).setup(Arrays.asList(message));
verify(footerPresenter).setup(container.getUrl(), resolvedReleasedId.getVersion());
verify(cardPresenter).addTitle(linkTitlePresenter);
verify(cardPresenter).addTitle(infoTitlePresenter);
verify(cardPresenter).addBody(bodyPresenter);
verify(cardPresenter).addFooter(footerPresenter);
verify(view).setCard(cardPresenterView);
linkTitlePresenter.onSelect();
final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), ""));
verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey)));
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class AsyncKieServerInstanceManager method produceContainerUpdateEvent.
protected void produceContainerUpdateEvent(ServerTemplate serverTemplate, ContainerSpec containerSpec, List<Container> containers, ContainerRuntimeOperation containerRuntimeOperation) {
List<ServerInstanceKey> failedServerInstances = new ArrayList<ServerInstanceKey>();
for (Container container : containers) {
if (hasIssues(container)) {
failedServerInstances.add(container.getServerInstanceKey());
}
}
ContainerRuntimeState containerRuntimeState = ContainerRuntimeState.ONLINE;
if (failedServerInstances.size() == containers.size()) {
containerRuntimeState = ContainerRuntimeState.OFFLINE;
} else if (!failedServerInstances.isEmpty()) {
containerRuntimeState = ContainerRuntimeState.PARTIAL_ONLINE;
}
ContainerUpdateEvent updateEvent = new ContainerUpdateEvent(serverTemplate, containerSpec, failedServerInstances, containerRuntimeState, containerRuntimeOperation);
containerUpdateEvent.fire(updateEvent);
}
use of org.kie.server.controller.api.model.runtime.Container 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.server.controller.api.model.runtime.Container 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);
}
Aggregations