use of org.kie.server.controller.api.model.spec.ServerTemplateKey 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.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorageTest method testStoreLoadAndUpdateServerTemplate.
@Test
public void testStoreLoadAndUpdateServerTemplate() {
templateStorage.store(serverTemplate);
ServerTemplate fromStorage = templateStorage.load(serverTemplate.getId());
assertNotNull(fromStorage);
assertEquals(serverTemplate.getId(), fromStorage.getId());
assertEquals(serverTemplate.getName(), fromStorage.getName());
// let's add new container
ContainerSpec newContainerSpec = new ContainerSpec();
newContainerSpec.setId("test container 2");
newContainerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
newContainerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "3.0"));
newContainerSpec.setStatus(KieContainerStatus.STARTED);
fromStorage.addContainerSpec(newContainerSpec);
// now let's add server instance
fromStorage.addServerInstance(ModelFactory.newServerInstanceKey(serverTemplate.getId(), "http://localhost:8080/server"));
templateStorage.update(fromStorage);
ServerTemplate template = templateStorage.load(serverTemplate.getId());
assertNotNull(template);
assertEquals(serverTemplate.getId(), template.getId());
assertEquals(serverTemplate.getName(), template.getName());
Collection<ServerInstanceKey> instances = template.getServerInstanceKeys();
assertNotNull(instances);
assertEquals(1, instances.size());
ServerInstanceKey serverInstanceKey = instances.iterator().next();
assertNotNull(serverInstanceKey);
assertEquals(serverTemplate.getId(), serverInstanceKey.getServerTemplateId());
assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerName());
assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerInstanceId());
assertEquals("http://localhost:8080/server", serverInstanceKey.getUrl());
Collection<ContainerSpec> containerSpecs = template.getContainersSpec();
assertNotNull(containerSpecs);
assertEquals(2, containerSpecs.size());
Iterator<ContainerSpec> iterator = containerSpecs.iterator();
// first container spec...
ContainerSpec spec = 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());
// second container spec
spec = iterator.next();
assertNotNull(spec);
assertEquals(newContainerSpec.getId(), spec.getId());
assertEquals(newContainerSpec.getReleasedId(), spec.getReleasedId());
assertEquals(newContainerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
assertEquals(newContainerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
assertEquals(newContainerSpec.getConfigs().size(), spec.getConfigs().size());
}
use of org.kie.server.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorageTest method createServerTemplateWithContainer.
/*
* helper method to setup template container and container spec
*/
protected void createServerTemplateWithContainer() {
serverTemplate = new ServerTemplate();
serverTemplate.setName("test server");
serverTemplate.setId(UUID.randomUUID().toString());
Map<Capability, ContainerConfig> configs = new HashMap<Capability, ContainerConfig>();
ruleConfig = new RuleConfig();
ruleConfig.setPollInterval(1000l);
ruleConfig.setScannerStatus(KieScannerStatus.STARTED);
configs.put(Capability.RULE, ruleConfig);
processConfig = new ProcessConfig();
processConfig.setKBase("defaultKieBase");
processConfig.setKSession("defaultKieSession");
processConfig.setMergeMode("MERGE_COLLECTION");
processConfig.setRuntimeStrategy("PER_PROCESS_INSTANCE");
configs.put(Capability.PROCESS, processConfig);
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(configs);
serverTemplate.addContainerSpec(containerSpec);
container = new Container();
container.setServerInstanceId(serverTemplate.getId());
container.setServerTemplateId(serverTemplate.getId());
container.setResolvedReleasedId(containerSpec.getReleasedId());
container.setContainerName(containerSpec.getContainerName());
container.setContainerSpecId(containerSpec.getId());
container.setUrl("http://fake.server.net/kie-server");
}
use of org.kie.server.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenter method setup.
public void setup(final Collection<ServerTemplateKey> serverTemplateKeys, final String selectServerTemplateId) {
if (serverTemplateKeys.isEmpty()) {
isEmpty = true;
this.view.setEmptyView(serverEmptyPresenter.getView());
navigationPresenter.clear();
} else {
isEmpty = false;
ServerTemplateKey serverTemplate2BeSelected = null;
if (selectServerTemplateId != null) {
for (ServerTemplateKey serverTemplateKey : serverTemplateKeys) {
if (serverTemplateKey.getId().equals(selectServerTemplateId)) {
serverTemplate2BeSelected = serverTemplateKey;
break;
}
}
}
if (serverTemplate2BeSelected == null) {
serverTemplate2BeSelected = serverTemplateKeys.iterator().next();
}
navigationPresenter.setup(serverTemplate2BeSelected, serverTemplateKeys);
serverTemplateSelectedEvent.fire(new ServerTemplateSelected(serverTemplate2BeSelected));
}
}
use of org.kie.server.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenterTest method testOnSelectedServerTemplate.
@Test
public void testOnSelectedServerTemplate() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
when(specManagementService.getServerTemplate(serverTemplateKey.getId())).thenReturn(serverTemplate);
final ServerTemplatePresenter.View serverView = mock(ServerTemplatePresenter.View.class);
when(serverTemplatePresenter.getView()).thenReturn(serverView);
final ServerContainerEmptyPresenter.View serverEmptyView = mock(ServerContainerEmptyPresenter.View.class);
when(serverContainerEmptyPresenter.getView()).thenReturn(serverEmptyView);
presenter.onSelected(new ServerTemplateSelected(serverTemplateKey));
verify(view).setServerTemplate(serverView);
verify(specManagementService).getServerTemplate(serverTemplateKey.getId());
verify(serverContainerEmptyPresenter).setTemplate(serverTemplate);
verify(view).setContent(serverEmptyView);
verify(serverTemplatePresenter).setup(serverTemplate, null);
}
Aggregations