Search in sources :

Example 11 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnSelectedNonEmptyServerTemplate.

@Test
public void testOnSelectedNonEmptyServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    final ContainerSpec toBeSelected = mock(ContainerSpec.class);
    serverTemplate.addContainerSpec(toBeSelected);
    when(toBeSelected.getId()).thenReturn("other-id");
    final ContainerSpec forcedToBeSelected = mock(ContainerSpec.class);
    when(forcedToBeSelected.getId()).thenReturn("container-id");
    serverTemplate.addContainerSpec(forcedToBeSelected);
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
    when(specManagementService.getServerTemplate(serverTemplateKey.getId())).thenReturn(serverTemplate);
    final ServerTemplatePresenter.View serverView = mock(ServerTemplatePresenter.View.class);
    when(serverTemplatePresenter.getView()).thenReturn(serverView);
    presenter.onSelected(new ServerTemplateSelected(serverTemplateKey));
    verify(view).setServerTemplate(serverView);
    verify(specManagementService).getServerTemplate(serverTemplateKey.getId());
    verify(serverTemplatePresenter).setup(serverTemplate, toBeSelected);
    presenter.onSelected(new ServerTemplateSelected(serverTemplateKey, "container-id"));
    verify(serverTemplatePresenter).setup(serverTemplate, forcedToBeSelected);
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplatePresenter(org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Example 12 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec 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 13 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec 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();
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 14 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class BuildExecutorTest method testBuildAndDeployCommandSingleServerTemplateContainerExists.

@Test
public void testBuildAndDeployCommandSingleServerTemplateContainerExists() {
    final String containerId = module.getPom().getGav().getArtifactId() + "_" + module.getPom().getGav().getVersion();
    final String containerName = module.getPom().getGav().getArtifactId();
    final ServerTemplate serverTemplate = new ServerTemplate("id", "name");
    serverTemplate.addContainerSpec(new ContainerSpec(containerId, containerName, null, null, null, null));
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Collections.singletonList(serverTemplate)));
    buildExecutor.triggerBuildAndDeploy();
    verify(deploymentScreenPopupView).setValidateExistingContainerCallback(any(DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback.class));
    verify(deploymentScreenPopupView).setContainerId(containerId);
    verify(deploymentScreenPopupView).setContainerAlias(containerName);
    verify(deploymentScreenPopupView).setStartContainer(true);
    verify(deploymentScreenPopupView).configure(any(com.google.gwt.user.client.Command.class));
    verify(deploymentScreenPopupView).show();
    verifyNoMoreInteractions(deploymentScreenPopupView);
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Command(org.uberfire.mvp.Command) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 15 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class DeploymentPopupBuilderTest method containerSpec.

private ContainerSpec containerSpec(final String containerName) {
    final ContainerSpec containerSpec = mock(ContainerSpec.class);
    doReturn(containerName).when(containerSpec).getContainerName();
    return containerSpec;
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec)

Aggregations

ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)33 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)22 Test (org.junit.Test)20 ReleaseId (org.kie.server.api.model.ReleaseId)13 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)10 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)8 Container (org.kie.server.controller.api.model.runtime.Container)7 Capability (org.kie.server.controller.api.model.spec.Capability)7 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)7 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)6 HashMap (java.util.HashMap)5 Path (org.uberfire.java.nio.file.Path)5 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)4 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GAV (org.guvnor.common.services.project.model.GAV)3 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)3