Search in sources :

Example 56 with ServerTemplate

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

the class ServerTemplatePresenterTest method testOnServerInstanceUpdated.

@Test
public void testOnServerInstanceUpdated() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    presenter.setup(serverTemplate, null);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    final ServerInstance serverInstance = new ServerInstance(serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    verify(view).addServerInstance(eq(serverInstance.getServerTemplateId()), eq(serverInstance.getServerInstanceId()), eq(serverInstance.getServerName()), any(Command.class));
    presenter.onServerInstanceDeleted(new ServerInstanceDeleted(serverInstance.getServerInstanceId()));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    verify(view, times(2)).addServerInstance(eq(serverInstance.getServerTemplateId()), eq(serverInstance.getServerInstanceId()), eq(serverInstance.getServerName()), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 57 with ServerTemplate

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

the class ServerTemplatePresenterTest method testSetup.

@Test
public void testSetup() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverTemplateId", "serverName", "serverInstanceId", "url");
    serverTemplate.addServerInstance(serverInstanceKey);
    final ReleaseId releaseId = new ReleaseId("org.kie", "container", "1.0.0");
    final ContainerSpec containerSpec = new ContainerSpec("containerId", "containerName", serverTemplate, releaseId, KieContainerStatus.CREATING, null);
    serverTemplate.addContainerSpec(containerSpec);
    final ContainerSpec containerSpec1 = new ContainerSpec("containerId1", "containerName1", serverTemplate, new ReleaseId("org.kie", "container2", "1.0.0"), KieContainerStatus.CREATING, null);
    serverTemplate.addContainerSpec(containerSpec1);
    presenter.setup(serverTemplate, containerSpec);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    verify(view).clear();
    verify(view).setTemplate(serverTemplate.getId(), serverTemplate.getName());
    verify(view).setProcessCapability(false);
    verify(view).setRulesCapability(false);
    verify(view).setPlanningCapability(false);
    verify(view).addContainer(eq(containerSpec.getServerTemplateKey().getId()), eq(containerSpec.getId()), eq(containerSpec.getContainerName()), any(Command.class));
    verify(view).addContainer(eq(containerSpec1.getServerTemplateKey().getId()), eq(containerSpec1.getId()), eq(containerSpec1.getContainerName()), any(Command.class));
    final ArgumentCaptor<ContainerSpecSelected> selectedCaptor = ArgumentCaptor.forClass(ContainerSpecSelected.class);
    verify(containerSpecSelectedEvent).fire(selectedCaptor.capture());
    assertEquals(containerSpec, selectedCaptor.getValue().getContainerSpecKey());
    verify(view).addServerInstance(eq(serverInstanceKey.getServerTemplateId()), eq(serverInstanceKey.getServerInstanceId()), eq(serverInstanceKey.getServerName()), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Example 58 with ServerTemplate

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

the class NewContainerWizardTest method testComplete.

@Test
public void testComplete() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
    final ContainerSpec containerSpec = new ContainerSpec();
    containerSpec.setId("containerSpecId");
    when(newContainerFormPresenter.buildContainerSpec(eq(serverTemplate.getId()), anyMap())).thenReturn(containerSpec);
    when(newContainerFormPresenter.getServerTemplate()).thenReturn(serverTemplate);
    final String successMessage = "SUCCESS";
    when(newContainerFormPresenterView.getNewContainerWizardSaveSuccess()).thenReturn(successMessage);
    newContainerWizard.setServerTemplate(serverTemplate);
    newContainerWizard.complete();
    verify(processConfigPagePresenter).buildProcessConfig();
    verify(newContainerFormPresenter).buildContainerSpec(eq(serverTemplate.getId()), anyMap());
    final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
    verify(notification).fire(eventCaptor.capture());
    final NotificationEvent event = eventCaptor.getValue();
    assertEquals(successMessage, event.getNotification());
    assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType());
    final ArgumentCaptor<ServerTemplateSelected> serverTemplateEventCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
    verify(serverTemplateSelectedEvent).fire(serverTemplateEventCaptor.capture());
    final ServerTemplateSelected serverEvent = serverTemplateEventCaptor.getValue();
    assertEquals(serverTemplate, serverEvent.getServerTemplateKey());
    assertEquals(containerSpec.getId(), serverEvent.getContainerId());
    verifyClear();
    doThrow(new RuntimeException()).when(specManagementService).saveContainerSpec(anyString(), any(ContainerSpec.class));
    final String errorMessage = "ERROR";
    when(newContainerFormPresenterView.getNewContainerWizardSaveError()).thenReturn(errorMessage);
    newContainerWizard.complete();
    verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
    verify(newContainerWizard).pageSelected(0);
    verify(newContainerWizard).start();
    verify(newContainerFormPresenter).initialise();
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Example 59 with ServerTemplate

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

the class NewContainerFormPresenterTest method testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsNotEmpty.

@Test
public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsNotEmpty() {
    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("custom");
    presenter.setServerTemplate(serverTemplate);
    presenter.asWidget();
    presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path));
    verify(view, never()).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)

Example 60 with ServerTemplate

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

the class NewContainerFormPresenterTest method testIsValid.

@Test
public void testIsValid() {
    when(view.getContainerName()).thenReturn(" ").thenReturn("containerName").thenReturn("");
    when(view.getGroupId()).thenReturn(" ").thenReturn("groupId").thenReturn("");
    when(view.getArtifactId()).thenReturn(" ").thenReturn("artifactId").thenReturn("");
    when(view.getVersion()).thenReturn(" ").thenReturn("1.0").thenReturn("");
    assertTrue(presenter.isValid());
    verify(view).noErrors();
    presenter.setServerTemplate(new ServerTemplate());
    assertTrue(presenter.isValid());
    verify(view).noErrorOnContainerName();
    verify(view).noErrorOnGroupId();
    verify(view).noErrorOnArtifactId();
    verify(view).noErrorOnVersion();
    assertFalse(presenter.isValid());
    verify(view).errorOnContainerName();
    verify(view).errorOnGroupId();
    verify(view).errorOnArtifactId();
    verify(view).errorOnVersion();
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) 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