use of org.kie.server.controller.api.model.runtime.Container 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.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class ContainerRemoteStatusPresenterTest method testOnDelete.
@Test
public void testOnDelete() {
final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
when(presenterProvider.get()).thenReturn(cardPresenter);
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.<Message>emptyList(), null, null);
container.setStatus(KieContainerStatus.STARTED);
presenter.setup(new ContainerSpec(), Collections.singletonList(container));
verify(view).clear();
verify(cardPresenter).setup(container.getServerInstanceKey(), container);
verify(view).addCard(any(IsWidget.class));
presenter.onDelete(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId()));
verify(cardPresenter).delete();
presenter.onDelete(new ServerInstanceDeleted("randomKey"));
verify(cardPresenter).delete();
}
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 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(serverInstanceKey, container);
verify(linkTitlePresenter).setup(eq(serverInstanceKey.getServerName()), any(Command.class));
verify(bodyPresenter).setup(Arrays.asList(message));
verify(footerPresenter).setup(container.getUrl(), resolvedReleasedId.getVersion());
verify(cardPresenter).addTitle(linkTitlePresenter);
verify(cardPresenter).addBody(bodyPresenter);
verify(cardPresenter).addFooter(footerPresenter);
verify(view).setCard(cardPresenterView);
linkTitlePresenter.onSelect();
verify(remoteServerSelectedEvent).fire(eq(new ServerInstanceSelected(serverInstanceKey)));
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class AsyncKieServerInstanceManagerTest method createContainers.
protected List<Container> createContainers(KieContainerStatus status, List<Message> messages, int instances) {
List<Container> containerList = new ArrayList<Container>();
for (int i = 0; i < instances; i++) {
Container container = new Container("c" + i, "name" + i, new ServerInstanceKey(serverTemplate.getId(), serverTemplate.getName(), serverTemplate.getId(), "http://testurl.com"), messages, null, "");
container.setStatus(status);
containerList.add(container);
}
return containerList;
}
use of org.kie.server.controller.api.model.runtime.Container in project kie-wb-common by kiegroup.
the class RuntimeManagementServiceCDITest method getContainersByServerInstance_returnsEmptyList_whenInstanceWithIdDoesntExistInTemplate.
@Test
public void getContainersByServerInstance_returnsEmptyList_whenInstanceWithIdDoesntExistInTemplate() {
final String templateId = "templateId";
final String serverInstanceId = "serverInstanceId";
KieServerTemplateStorage templateStorageMock = mock(KieServerTemplateStorage.class);
when(templateStorageMock.load(eq(templateId))).thenReturn(new ServerTemplate(null, null, Collections.emptyList(), Collections.emptyMap(), Collections.emptyList(), Collections.emptyList()));
// Setup tested service
runtimeManagementService.setTemplateStorage(templateStorageMock);
specManagementService.setTemplateStorage(templateStorageMock);
// Tested method
Collection<Container> containers = runtimeManagementServiceCDI.getContainersByServerInstance(templateId, serverInstanceId);
assertThat(containers).as("List of containers should be empty, when Server template doesn't contain server instance id").isEmpty();
}
Aggregations