Search in sources :

Example 1 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class ServerTemplatePresenterTest method testSetupCapabilities.

@Test
public void testSetupCapabilities() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
    serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
    serverTemplate.getCapabilities().add(Capability.PLANNING.toString());
    serverTemplate.getCapabilities().add(Capability.RULE.toString());
    presenter.setup(serverTemplate, null);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    verify(view).clear();
    verify(view).setTemplate(serverTemplate.getId(), serverTemplate.getName());
    verify(view).setProcessCapability(true);
    verify(view).setRulesCapability(true);
    verify(view).setPlanningCapability(true);
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Test(org.junit.Test)

Example 2 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class ServerTemplatePresenterTest method testCopyTemplate.

@Test
public void testCopyTemplate() {
    final String newTemplateName = "NewTemplateName";
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final ParameterizedCommand command = (ParameterizedCommand) invocation.getArguments()[0];
            if (command != null) {
                command.execute(newTemplateName);
            }
            return null;
        }
    }).when(copyPresenter).copy(any(ParameterizedCommand.class));
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
    presenter.setup(serverTemplate, null);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    presenter.copyTemplate();
    verify(specManagementService).copyServerTemplate(serverTemplate.getId(), newTemplateName, newTemplateName);
    verify(copyPresenter).hide();
    final ArgumentCaptor<ServerTemplateListRefresh> serverTemplateCaptor = ArgumentCaptor.forClass(ServerTemplateListRefresh.class);
    verify(serverTemplateListRefreshEvent).fire(serverTemplateCaptor.capture());
    assertEquals(newTemplateName, serverTemplateCaptor.getValue().getSelectServerTemplateId());
    doThrow(new RuntimeException()).when(specManagementService).copyServerTemplate(serverTemplate.getId(), newTemplateName, newTemplateName);
    presenter.copyTemplate();
    verify(specManagementService, times(2)).copyServerTemplate(serverTemplate.getId(), newTemplateName, newTemplateName);
    verify(copyPresenter).errorDuringProcessing(anyString());
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ServerTemplateListRefresh(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateListRefresh) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Test(org.junit.Test)

Example 3 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class ServerTemplatePresenterTest method testOnServerInstanceUpdatedWithoutCurrentServer.

@Test
public void testOnServerInstanceUpdatedWithoutCurrentServer() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    final ServerInstance serverInstance = new ServerInstance(serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    verify(view, never()).addServerInstance(anyString(), anyString(), anyString(), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 4 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class NewContainerWizardTest method testSetServerTemplate.

@Test
public void testSetServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
    newContainerWizard.setServerTemplate(serverTemplate);
    verify(newContainerFormPresenter).setServerTemplate(serverTemplate);
    assertEquals(2, newContainerWizard.getPages().size());
    assertTrue(newContainerWizard.getPages().contains(newContainerFormPresenter));
    assertTrue(newContainerWizard.getPages().contains(processConfigPagePresenter));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Test(org.junit.Test)

Example 5 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class NewContainerFormPresenterTest method testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsEmpty.

@Test
public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsEmpty() {
    final String path = "org:kie:1.0";
    final String templateId = "templateId";
    final GAV gav = new GAV(path);
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    when(serverTemplate.getId()).thenReturn(templateId);
    when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav);
    when(specManagementService.validContainerId(templateId, path)).thenReturn(path);
    when(view.getContainerName()).thenReturn("");
    presenter.setServerTemplate(serverTemplate);
    presenter.asWidget();
    presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path));
    verify(view).setContainerName(path);
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Matchers.anyString(org.mockito.Matchers.anyString) GAV(org.guvnor.common.services.project.model.GAV) DependencyPathSelectedEvent(org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent) 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