use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class NewServerTemplateWizard method buildServerTemplate.
private ServerTemplate buildServerTemplate() {
final Collection<String> capabilities = new ArrayList<String>();
final Map<Capability, ServerConfig> capabilityConfig = new HashMap<Capability, ServerConfig>();
final Map<Capability, ContainerConfig> capabilityContainerConfig = new HashMap<Capability, ContainerConfig>();
final Collection<ContainerSpec> containersSpec = new ArrayList<ContainerSpec>();
if (newTemplatePresenter.isProcessCapabilityChecked()) {
capabilities.add(Capability.PROCESS.toString());
if (!newContainerFormPresenter.isEmpty()) {
capabilityContainerConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig());
}
}
capabilityContainerConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED));
if (newTemplatePresenter.isRuleCapabilityChecked()) {
capabilities.add(Capability.RULE.toString());
}
if (newTemplatePresenter.isPlanningCapabilityChecked()) {
capabilities.add(Capability.PLANNING.toString());
}
if (!newContainerFormPresenter.isEmpty()) {
containersSpec.add(newContainerFormPresenter.buildContainerSpec(newTemplatePresenter.getTemplateName(), capabilityContainerConfig));
}
return new ServerTemplate(newTemplatePresenter.getTemplateName(), newTemplatePresenter.getTemplateName(), capabilities, capabilityConfig, containersSpec);
}
use of org.kie.server.controller.api.model.spec.ServerTemplate 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);
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenterTest method testOnServerTemplateUpdated.
@Test
public void testOnServerTemplateUpdated() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
presenter.onServerTemplateUpdated(new ServerTemplateUpdated(serverTemplate));
final ArgumentCaptor<Collection> serverTemplateKeysCaptor = ArgumentCaptor.forClass(Collection.class);
verify(navigationPresenter).setup(eq(serverTemplate), serverTemplateKeysCaptor.capture());
final Collection<ServerTemplateKey> serverTemplateKeys = serverTemplateKeysCaptor.getValue();
assertEquals(1, serverTemplateKeys.size());
assertTrue(serverTemplateKeys.contains(serverTemplate));
final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
verify(serverTemplateSelectedEvent).fire(templateSelectedCaptor.capture());
assertEquals(serverTemplate, templateSelectedCaptor.getValue().getServerTemplateKey());
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerNavigationPresenterTest method testOnServerTemplateUpdated.
@Test
public void testOnServerTemplateUpdated() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
presenter.onServerTemplateUpdated(new ServerTemplateUpdated(serverTemplate));
verify(view).addTemplate(serverTemplate.getId(), serverTemplate.getName());
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerTemplatePresenterTest method testRemoveTemplate.
@Test
public void testRemoveTemplate() {
when(view.getRemoveTemplateErrorMessage()).thenReturn("ERROR");
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
Command command = (Command) invocation.getArguments()[0];
if (command != null) {
command.execute();
}
return null;
}
}).when(view).confirmRemove(any(Command.class));
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
presenter.setup(serverTemplate, null);
presenter.removeTemplate();
verify(specManagementService).deleteServerTemplate(serverTemplate.getId());
verify(serverTemplateListRefreshEvent).fire(any(ServerTemplateListRefresh.class));
doThrow(new RuntimeException()).when(specManagementService).deleteServerTemplate(serverTemplate.getId());
presenter.removeTemplate();
verify(specManagementService, times(2)).deleteServerTemplate(serverTemplate.getId());
verify(serverTemplateListRefreshEvent, times(2)).fire(any(ServerTemplateListRefresh.class));
verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
}
Aggregations