use of org.kie.server.controller.api.model.spec.ServerTemplateKey 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.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorageTest method testStoreLoadAndDeleteServerTemplate.
@Test
public void testStoreLoadAndDeleteServerTemplate() {
templateStorage.store(serverTemplate);
Collection<ServerTemplateKey> templateKeys = templateStorage.loadKeys();
assertNotNull(templateKeys);
assertEquals(1, templateKeys.size());
templateStorage.delete(serverTemplate.getId());
boolean exists = templateStorage.exists(serverTemplate.getId());
assertFalse(exists);
ServerTemplate template = templateStorage.load("not existing");
assertNull(template);
templateKeys = templateStorage.loadKeys();
assertNotNull(templateKeys);
assertEquals(0, templateKeys.size());
}
use of org.kie.server.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenterTest method testOnDelete.
@Test
public void testOnDelete() {
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverInstanceKeyId", "serverName", "serverInstanceId", "url");
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
serverTemplate.addServerInstance(serverInstanceKey);
when(serverTemplatePresenter.getCurrentServerTemplate()).thenReturn(serverTemplate);
final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList(serverTemplateKey);
when(specManagementService.listServerTemplateKeys()).thenReturn(new ServerTemplateKeyList(serverTemplateKeys));
presenter.onDelete(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId()));
verify(navigationPresenter).setup(serverTemplateKey, serverTemplateKeys);
final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
verify(serverTemplateSelectedEvent).fire(templateSelectedCaptor.capture());
assertEquals(serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey());
}
use of org.kie.server.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenterTest method testOnSelectedNonEmptyServerTemplate.
@Test
public void testOnSelectedNonEmptyServerTemplate() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
final ContainerSpec toBeSelected = mock(ContainerSpec.class);
serverTemplate.addContainerSpec(toBeSelected);
when(toBeSelected.getId()).thenReturn("other-id");
final ContainerSpec forcedToBeSelected = mock(ContainerSpec.class);
when(forcedToBeSelected.getId()).thenReturn("container-id");
serverTemplate.addContainerSpec(forcedToBeSelected);
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);
presenter.onSelected(new ServerTemplateSelected(serverTemplateKey));
verify(view).setServerTemplate(serverView);
verify(specManagementService).getServerTemplate(serverTemplateKey.getId());
verify(serverTemplatePresenter).setup(serverTemplate, toBeSelected);
presenter.onSelected(new ServerTemplateSelected(serverTemplateKey, "container-id"));
verify(serverTemplatePresenter).setup(serverTemplate, forcedToBeSelected);
}
use of org.kie.server.controller.api.model.spec.ServerTemplateKey in project kie-wb-common by kiegroup.
the class ServerNavigationPresenter method setup.
public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) {
view.clean();
serverTemplates.clear();
addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate));
for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) {
if (!serverTemplateKey.equals(firstTemplate)) {
addTemplate(serverTemplateKey);
}
}
}
Aggregations