Search in sources :

Example 6 with ReleaseId

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

the class ContainerRulesConfigPresenterTest method testUpgrade.

@Test
public void testUpgrade() {
    final String version = "1.0";
    presenter.setup(containerSpec, ruleConfig);
    presenter.upgrade(version);
    verify(view).disableActions();
    final ArgumentCaptor<ReleaseId> releaseIdCaptor = ArgumentCaptor.forClass(ReleaseId.class);
    verify(ruleCapabilitiesService).upgradeContainer(eq(containerSpec), releaseIdCaptor.capture());
    assertEquals(version, releaseIdCaptor.getValue().getVersion());
    verify(view).setStartScannerState(State.ENABLED);
    verify(view).setStopScannerState(State.DISABLED);
    verify(view).setScanNowState(State.ENABLED);
    verify(view).setUpgradeState(State.ENABLED);
    verify(notification).fire(new NotificationEvent(SUCCESS_UPGRADE, NotificationEvent.NotificationType.SUCCESS));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Example 7 with ReleaseId

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

the class ContainerRulesConfigPresenterTest method init.

@Before
public void init() {
    releaseId = new ReleaseId();
    releaseId.setVersion("0.1");
    doNothing().when(notification).fire(any(NotificationEvent.class));
    ruleCapabilitiesServiceCaller = new CallerMock<RuleCapabilitiesService>(ruleCapabilitiesService);
    when(containerSpec.getReleasedId()).thenReturn(releaseId);
    when(view.getUpgradeSuccessMessage()).thenReturn(SUCCESS_UPGRADE);
    presenter = new ContainerRulesConfigPresenter(logger, view, ruleCapabilitiesServiceCaller, notification);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            releaseId.setVersion(invocation.getArgumentAt(1, ReleaseId.class).getVersion());
            return null;
        }
    }).when(ruleCapabilitiesService).upgradeContainer(any(ContainerSpecKey.class), any(ReleaseId.class));
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RuleCapabilitiesService(org.kie.workbench.common.screens.server.management.service.RuleCapabilitiesService) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ReleaseId(org.kie.server.api.model.ReleaseId) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) Before(org.junit.Before)

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

Example 9 with ReleaseId

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

the class BuildExecutor method makeContainerSpec.

private ContainerSpec makeContainerSpec(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final Map<String, String> parameters) {
    final ReleaseId releaseId = makeReleaseId();
    final KieContainerStatus status = KieContainerStatus.STOPPED;
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getId());
    return new ContainerSpec(containerId, containerAlias, serverTemplateKey, releaseId, status, makeConfigs(serverTemplate, parameters));
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ReleaseId(org.kie.server.api.model.ReleaseId) KieContainerStatus(org.kie.server.api.model.KieContainerStatus)

Example 10 with ReleaseId

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

the class ServerTemplateMigrationTest method testMigrationOfOldServerTemplateWithContainers.

@Test
public void testMigrationOfOldServerTemplateWithContainers() throws Exception {
    String serverTemplateId = "kie_server";
    String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info-with-containers.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);
    assertEquals(0, capabilities.size());
    // verify server instances (previously known as managedInstances)
    Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(0, instances.size());
    // verify containers
    Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(1, containerSpecs.size());
    Iterator<ContainerSpec> iterator = containerSpecs.iterator();
    // first container spec...
    ContainerSpec spec = iterator.next();
    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)

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