use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class RuntimeManagementServiceCDITest method getContainersByServerInstance_returnsListOfContainers_whenInstanceWithIdExists.
@Test
public void getContainersByServerInstance_returnsListOfContainers_whenInstanceWithIdExists() {
final String templateId = "templateId";
final String templateName = "templateName";
final String serverInstanceId = "serverInstanceId";
ServerInstanceKey serverInstanceKey = new ServerInstanceKey(templateId, templateName, serverInstanceId, "dummyUrl");
ServerTemplate serverTemplate = new ServerTemplate(templateId, templateName, Collections.emptyList(), Collections.emptyMap(), Collections.emptyList(), Collections.singletonList(serverInstanceKey));
final List<Container> containersInServerInstance = Arrays.asList(new Container(), new Container());
KieServerTemplateStorage templateStorageMock = createMockStorageWithOneTemplate(serverTemplate);
// Instance with 2 dummy containers
KieServerInstanceManager instanceMangerMock = mock(KieServerInstanceManager.class);
when(instanceMangerMock.getContainers(eq(serverInstanceKey))).thenReturn(containersInServerInstance);
runtimeManagementService.setTemplateStorage(templateStorageMock);
runtimeManagementService.setKieServerInstanceManager(instanceMangerMock);
specManagementService.setTemplateStorage(templateStorageMock);
specManagementService.setKieServerInstanceManager(instanceMangerMock);
Collection<Container> containers = runtimeManagementServiceCDI.getContainersByServerInstance(templateId, serverInstanceId);
assertThat(containers).as("Should return list of containers from server instance id").hasSameSizeAs(containersInServerInstance);
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class ContainerRemoteStatusPresenter method onServerInstanceUpdated.
public void onServerInstanceUpdated(@Observes final ServerInstanceUpdated serverInstanceUpdated) {
if (serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null) {
final String updatedServerInstanceKey = serverInstanceUpdated.getServerInstance().getServerInstanceId();
if (index.containsKey(updatedServerInstanceKey)) {
final Map<String, ContainerCardPresenter> oldIndex = new HashMap<String, ContainerCardPresenter>(index.remove(updatedServerInstanceKey));
final Map<String, ContainerCardPresenter> newIndexIndex = new HashMap<String, ContainerCardPresenter>(serverInstanceUpdated.getServerInstance().getContainers().size());
index.put(updatedServerInstanceKey, newIndexIndex);
for (final Container container : serverInstanceUpdated.getServerInstance().getContainers()) {
ContainerCardPresenter presenter = oldIndex.remove(container.getContainerName());
if (!container.getStatus().equals(KieContainerStatus.STOPPED)) {
if (presenter != null) {
presenter.updateContent(serverInstanceUpdated.getServerInstance(), container);
} else {
presenter = buildContainer(container);
}
newIndexIndex.put(container.getContainerName(), presenter);
}
}
for (final ContainerCardPresenter presenter : oldIndex.values()) {
presenter.delete();
}
} else {
for (final Container container : serverInstanceUpdated.getServerInstance().getContainers()) {
if (container.getServerTemplateId().equals(containerSpec.getServerTemplateKey().getId()) && container.getContainerSpecId().equals(containerSpec.getId())) {
buildAndIndexContainer(container);
}
}
}
} else {
logger.warn("Illegal event argument.");
}
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class ContainerRemoteStatusPresenter method setup.
public void setup(final ContainerSpec containerSpec, final Collection<Container> containers) {
this.containerSpec = containerSpec;
this.view.clear();
for (Container container : containers) {
if (!container.getStatus().equals(KieContainerStatus.STOPPED)) {
buildAndIndexContainer(container);
}
}
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class RemoteStatusPresenter method setup.
public void setup(final Collection<Container> containers) {
view.clear();
for (final Container container : containers) {
final ContainerCardPresenter newCard = presenterProvider.get();
newCard.setup(container);
view.addCard(newCard.getView().asWidget());
}
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testLoadContainers.
@Test
public void testLoadContainers() {
final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null);
containerSpecData.getContainers().add(container);
presenter.loadContainers(containerSpecData);
verifyLoad(true, 1);
}
Aggregations