Search in sources :

Example 1 with ReleaseId

use of org.kie.server.api.model.ReleaseId 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)));
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Message(org.kie.server.api.model.Message) FooterPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter) ReleaseId(org.kie.server.api.model.ReleaseId) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) InfoTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.InfoTitlePresenter) Container(org.kie.server.controller.api.model.runtime.Container) Command(org.uberfire.mvp.Command) CardPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.CardPresenter) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) LinkTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.LinkTitlePresenter) BodyPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter) Test(org.junit.Test)

Example 2 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class AsyncKieServerInstanceManagerTest method prepare.

@Before
public void prepare() {
    returnedContainers.clear();
    serverTemplate = new ServerTemplate();
    serverTemplate.setName("test server");
    serverTemplate.setId(UUID.randomUUID().toString());
    containerSpec = new ContainerSpec();
    containerSpec.setId("test container");
    containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
    containerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "1.0"));
    containerSpec.setStatus(KieContainerStatus.STOPPED);
    containerSpec.setConfigs(new HashMap<Capability, ContainerConfig>());
    serverTemplate.addContainerSpec(containerSpec);
    this.kieServerInstanceManager = new AsyncKieServerInstanceManager(notificationService, containerUpdateEvent, executor) {

        @Override
        protected List<Container> callRemoteKieServerOperation(ServerTemplate serverTemplate, ContainerSpec containerSpec, RemoteKieServerOperation operation) {
            return returnedContainers;
        }
    };
    this.kieServerInstanceManager.setExecutor(executor);
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Capability(org.kie.server.controller.api.model.spec.Capability) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList) List(java.util.List) ReleaseId(org.kie.server.api.model.ReleaseId) Before(org.junit.Before)

Example 3 with ReleaseId

use of org.kie.server.api.model.ReleaseId 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);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerInstanceManager(org.kie.server.controller.impl.KieServerInstanceManager) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) KieServerTemplateStorage(org.kie.server.controller.api.storage.KieServerTemplateStorage) Test(org.junit.Test)

Example 4 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class ServerTemplateMigrationTest method testMigrationOfOldServerTemplate.

@Test
public void testMigrationOfOldServerTemplate() throws Exception {
    String serverTemplateId = "kie_server";
    String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info.xml"));
    assertNotNull(oldServerTemplateContent);
    Path path = buildPath(serverTemplateId);
    assertNotNull(path);
    // let's store it in the old way -info.xml file
    ioService.write(path, oldServerTemplateContent);
    ServerTemplateMigration templateMigration = new ServerTemplateMigration();
    templateMigration.migrate(path.getParent(), ioService, xstream, templateStorage);
    boolean exists = templateStorage.exists(serverTemplateId);
    assertTrue(exists);
    ServerTemplate fromStorage = templateStorage.load(serverTemplateId);
    assertNotNull(fromStorage);
    // verify server template
    assertEquals(serverTemplateId, fromStorage.getId());
    assertEquals("kie server name", fromStorage.getName());
    Collection<String> capabilities = fromStorage.getCapabilities();
    assertNotNull(capabilities);
    assertTrue(capabilities.contains("KieServer"));
    assertTrue(capabilities.contains("BRM"));
    assertTrue(capabilities.contains("BPM"));
    // verify server instances (previously known as managedInstances)
    Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ServerInstanceKey serverInstanceKey = instances.iterator().next();
    assertNotNull(serverInstanceKey);
    assertEquals(serverTemplateId, serverInstanceKey.getServerTemplateId());
    assertEquals("kie_server@localhost:8180", serverInstanceKey.getServerName());
    assertEquals("kie_server@localhost:8180", serverInstanceKey.getServerInstanceId());
    assertEquals("http://localhost:8180/kie-server/services/rest/server", serverInstanceKey.getUrl());
    // verify containers
    Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(3, containerSpecs.size());
    Map<String, ContainerSpec> containersById = mapContainers(containerSpecs);
    assertTrue(containersById.containsKey("project-1"));
    assertTrue(containersById.containsKey("project-2"));
    assertTrue(containersById.containsKey("project-3"));
    // first container spec...
    ContainerSpec spec = containersById.get("project-2");
    assertNotNull(spec);
    assertEquals("project-2", spec.getId());
    assertEquals(new ReleaseId("org.kie.server", "project-2", "1.0.0"), spec.getReleasedId());
    assertEquals(serverTemplateId, spec.getServerTemplateKey().getId());
    assertEquals("kie server name", spec.getServerTemplateKey().getName());
    assertEquals(KieContainerStatus.STARTED, spec.getStatus());
    assertEquals(0, spec.getConfigs().size());
    // second container spec
    spec = containersById.get("project-3");
    assertNotNull(spec);
    assertEquals("project-3", spec.getId());
    assertEquals(new ReleaseId("org.kie.server", "project-3", "1.0.0"), spec.getReleasedId());
    assertEquals(serverTemplateId, spec.getServerTemplateKey().getId());
    assertEquals("kie server name", spec.getServerTemplateKey().getName());
    assertEquals(KieContainerStatus.STOPPED, spec.getStatus());
    assertEquals(0, spec.getConfigs().size());
    // third container spec
    spec = containersById.get("project-1");
    assertNotNull(spec);
    assertEquals("project-1", spec.getId());
    assertEquals(new ReleaseId("org.kie.server", "project-1", "1.0.0"), spec.getReleasedId());
    assertEquals(serverTemplateId, spec.getServerTemplateKey().getId());
    assertEquals("kie server name", spec.getServerTemplateKey().getName());
    assertEquals(KieContainerStatus.STARTED, spec.getStatus());
    assertEquals(0, spec.getConfigs().size());
}
Also used : Path(org.uberfire.java.nio.file.Path) ServerTemplateMigration(org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Example 5 with ReleaseId

use of org.kie.server.api.model.ReleaseId 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)

Aggregations

ReleaseId (org.kie.server.api.model.ReleaseId)18 Test (org.junit.Test)12 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)12 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)8 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)7 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)7 Container (org.kie.server.controller.api.model.runtime.Container)6 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 Before (org.junit.Before)3 Capability (org.kie.server.controller.api.model.spec.Capability)3 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)3 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)3 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)3 Command (org.uberfire.mvp.Command)3 HashMap (java.util.HashMap)2 GAV (org.guvnor.common.services.project.model.GAV)2 Message (org.kie.server.api.model.Message)2 ContainerSpecKey (org.kie.server.controller.api.model.spec.ContainerSpecKey)2 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)2 ContainerSpecSelected (org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected)2