use of org.kie.server.controller.api.model.spec.ContainerSpec 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.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorageTest method testStoreAndLoadServerTemplates.
@Test
public void testStoreAndLoadServerTemplates() {
templateStorage.store(serverTemplate);
Collection<ServerTemplateKey> templateKeys = templateStorage.loadKeys();
assertNotNull(templateKeys);
assertEquals(1, templateKeys.size());
ServerTemplateKey templateKey = templateKeys.iterator().next();
assertNotNull(templateKey);
assertEquals(serverTemplate.getId(), templateKey.getId());
assertEquals(serverTemplate.getName(), templateKey.getName());
Collection<ServerTemplate> templates = templateStorage.load();
assertNotNull(templates);
assertEquals(1, templates.size());
ServerTemplate template = templates.iterator().next();
assertNotNull(template);
assertEquals(serverTemplate.getId(), template.getId());
assertEquals(serverTemplate.getName(), template.getName());
Collection<ServerInstanceKey> instances = template.getServerInstanceKeys();
assertNotNull(instances);
assertEquals(0, instances.size());
Collection<ContainerSpec> containerSpecs = template.getContainersSpec();
assertNotNull(containerSpecs);
assertEquals(1, containerSpecs.size());
ContainerSpec spec = containerSpecs.iterator().next();
assertNotNull(spec);
assertEquals(containerSpec.getId(), spec.getId());
assertEquals(containerSpec.getReleasedId(), spec.getReleasedId());
assertEquals(containerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
assertEquals(containerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
assertEquals(containerSpec.getConfigs().size(), spec.getConfigs().size());
assertTrue(spec.getConfigs().containsKey(Capability.RULE));
assertTrue(spec.getConfigs().containsKey(Capability.PROCESS));
RuleConfig ruleConfig = (RuleConfig) spec.getConfigs().get(Capability.RULE);
assertNotNull(ruleConfig);
assertEquals(this.ruleConfig.getPollInterval(), ruleConfig.getPollInterval());
assertEquals(this.ruleConfig.getScannerStatus(), ruleConfig.getScannerStatus());
ProcessConfig processConfig = (ProcessConfig) spec.getConfigs().get(Capability.PROCESS);
assertNotNull(processConfig);
assertEquals(this.processConfig.getKBase(), processConfig.getKBase());
assertEquals(this.processConfig.getKSession(), processConfig.getKSession());
assertEquals(this.processConfig.getMergeMode(), processConfig.getMergeMode());
assertEquals(this.processConfig.getRuntimeStrategy(), processConfig.getRuntimeStrategy());
}
use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorageTest method testStoreServerTemplate.
@Test
public void testStoreServerTemplate() {
templateStorage.store(serverTemplate);
boolean exists = templateStorage.exists(serverTemplate.getId());
assertTrue(exists);
ServerTemplate fromStorage = templateStorage.load(serverTemplate.getId());
assertNotNull(fromStorage);
assertEquals(serverTemplate.getId(), fromStorage.getId());
assertEquals(serverTemplate.getName(), fromStorage.getName());
Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
assertNotNull(instances);
assertEquals(0, instances.size());
Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
assertNotNull(containerSpecs);
assertEquals(1, containerSpecs.size());
ContainerSpec spec = containerSpecs.iterator().next();
assertNotNull(spec);
assertEquals(containerSpec.getId(), spec.getId());
assertEquals(containerSpec.getReleasedId(), spec.getReleasedId());
assertEquals(containerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
assertEquals(containerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
assertEquals(containerSpec.getConfigs().size(), spec.getConfigs().size());
assertTrue(spec.getConfigs().containsKey(Capability.RULE));
assertTrue(spec.getConfigs().containsKey(Capability.PROCESS));
RuleConfig ruleConfig = (RuleConfig) spec.getConfigs().get(Capability.RULE);
assertNotNull(ruleConfig);
assertEquals(this.ruleConfig.getPollInterval(), ruleConfig.getPollInterval());
assertEquals(this.ruleConfig.getScannerStatus(), ruleConfig.getScannerStatus());
ProcessConfig processConfig = (ProcessConfig) spec.getConfigs().get(Capability.PROCESS);
assertNotNull(processConfig);
assertEquals(this.processConfig.getKBase(), processConfig.getKBase());
assertEquals(this.processConfig.getKSession(), processConfig.getKSession());
assertEquals(this.processConfig.getMergeMode(), processConfig.getMergeMode());
assertEquals(this.processConfig.getRuntimeStrategy(), processConfig.getRuntimeStrategy());
}
use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenter method setup.
private void setup(final ServerTemplate serverTemplate, final String selectContainerId) {
this.view.setServerTemplate(serverTemplatePresenter.getView());
ContainerSpec firstContainerSpec = null;
if (serverTemplate.getContainersSpec().isEmpty()) {
serverContainerEmptyPresenter.setTemplate(serverTemplate);
this.view.setContent(serverContainerEmptyPresenter.getView());
firstContainerSpec = null;
} else {
if (selectContainerId != null) {
for (final ContainerSpec containerSpec : serverTemplate.getContainersSpec()) {
if (containerSpec.getId().equals(selectContainerId)) {
firstContainerSpec = containerSpec;
break;
}
}
}
if (firstContainerSpec == null) {
firstContainerSpec = serverTemplate.getContainersSpec().iterator().next();
}
}
serverTemplatePresenter.setup(serverTemplate, firstContainerSpec);
}
use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.
the class ServerTemplatePresenter method setup.
public void setup(final ServerTemplate serverTemplate, final ContainerSpec firstContainerSpec) {
view.clear();
this.serverTemplate = serverTemplate;
view.setTemplate(serverTemplate.getId(), serverTemplate.getName());
view.setProcessCapability(serverTemplate.getCapabilities().contains(Capability.PROCESS.toString()));
view.setRulesCapability(serverTemplate.getCapabilities().contains(Capability.RULE.toString()));
view.setPlanningCapability(serverTemplate.getCapabilities().contains(Capability.PLANNING.toString()));
if (firstContainerSpec != null) {
addContainer(firstContainerSpec);
for (final ContainerSpec containerSpec : serverTemplate.getContainersSpec()) {
if (!containerSpec.getId().equals(firstContainerSpec.getId())) {
addContainer(containerSpec);
}
}
containerSpecSelectedEvent.fire(new ContainerSpecSelected(firstContainerSpec));
}
for (final ServerInstanceKey serverInstanceKey : serverTemplate.getServerInstanceKeys()) {
addServerInstance(serverInstanceKey);
}
}
Aggregations