Search in sources :

Example 51 with ServerTemplate

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);
}
Also used : Capability(org.kie.server.controller.api.model.spec.Capability) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList) ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ServerConfig(org.kie.server.controller.api.model.spec.ServerConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig)

Example 52 with ServerTemplate

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);
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplatePresenter(org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter) ServerContainerEmptyPresenter(org.kie.workbench.common.screens.server.management.client.container.empty.ServerContainerEmptyPresenter) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Example 53 with ServerTemplate

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());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Collection(java.util.Collection) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ServerTemplateUpdated(org.kie.server.controller.api.model.events.ServerTemplateUpdated) Test(org.junit.Test)

Example 54 with ServerTemplate

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());
}
Also used : AddNewServerTemplate(org.kie.workbench.common.screens.server.management.client.events.AddNewServerTemplate) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateUpdated(org.kie.server.controller.api.model.events.ServerTemplateUpdated) Test(org.junit.Test)

Example 55 with ServerTemplate

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));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateListRefresh(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateListRefresh) Test(org.junit.Test)

Aggregations

ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)61 Test (org.junit.Test)49 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)24 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)12 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)10 ArrayList (java.util.ArrayList)9 Capability (org.kie.server.controller.api.model.spec.Capability)9 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)9 Path (org.uberfire.java.nio.file.Path)9 ReleaseId (org.kie.server.api.model.ReleaseId)8 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)8 Command (org.uberfire.mvp.Command)7 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)7 Matchers.anyString (org.mockito.Matchers.anyString)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Container (org.kie.server.controller.api.model.runtime.Container)5 ValidateExistingContainerCallback (org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback)5 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)5