use of org.kie.server.controller.api.model.runtime.ServerInstanceKey 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.controller.api.model.runtime.ServerInstanceKey in project kie-wb-common by kiegroup.
the class AsyncKieServerInstanceManagerTest method createContainers.
protected List<Container> createContainers(KieContainerStatus status, List<Message> messages, int instances) {
List<Container> containerList = new ArrayList<Container>();
for (int i = 0; i < instances; i++) {
Container container = new Container("c" + i, "name" + i, new ServerInstanceKey(serverTemplate.getId(), serverTemplate.getName(), serverTemplate.getId(), "http://testurl.com"), messages, null, "");
container.setStatus(status);
containerList.add(container);
}
return containerList;
}
use of org.kie.server.controller.api.model.runtime.ServerInstanceKey in project kie-wb-common by kiegroup.
the class ServerTemplateMigrationTest method testMigrationOfServerTemplateOnly.
@Test
public void testMigrationOfServerTemplateOnly() throws Exception {
String serverTemplateId = "kie_server";
String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info-just-server.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(0, containerSpecs.size());
}
use of org.kie.server.controller.api.model.runtime.ServerInstanceKey in project kie-wb-common by kiegroup.
the class ServerTemplateMigrationTest method testMigrationOfOldServerTemplateWithInstances.
@Test
public void testMigrationOfOldServerTemplateWithInstances() throws Exception {
String serverTemplateId = "kie_server";
String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info-with-instances.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(0, containerSpecs.size());
}
use of org.kie.server.controller.api.model.runtime.ServerInstanceKey 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