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