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));
}
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));
}
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)));
}
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));
}
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());
}
Aggregations