Search in sources :

Example 1 with DependencyPathSelectedEvent

use of org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent in project kie-wb-common by kiegroup.

the class ArtifactListWidgetPresenterTest method testOnSelect.

@Test
public void testOnSelect() {
    presenter.onSelect("some path");
    verify(dependencyPathSelectedEvent).fire(new DependencyPathSelectedEvent(presenter, "some path"));
}
Also used : DependencyPathSelectedEvent(org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent) Test(org.junit.Test)

Example 2 with DependencyPathSelectedEvent

use of org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent 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)

Example 3 with DependencyPathSelectedEvent

use of org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent in project kie-wb-common by kiegroup.

the class NewContainerFormPresenterTest method testOnDependencyPathSelectedEventWithDefaultContainerNameWhenServerTemplateIsNull.

@Test
public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenServerTemplateIsNull() {
    final String path = "org:kie:1.0";
    final GAV gav = new GAV(path);
    when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav);
    when(view.getContainerName()).thenReturn("");
    presenter.setServerTemplate(null);
    presenter.asWidget();
    presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path));
    verify(view).setContainerName(path);
    verify(specManagementService, never()).validContainerId(anyString(), anyString());
}
Also used : 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 4 with DependencyPathSelectedEvent

use of org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent 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 5 with DependencyPathSelectedEvent

use of org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent in project kie-wb-common by kiegroup.

the class NewContainerFormPresenterTest method testOnDependencyPathSelectedEvent.

@Test
public void testOnDependencyPathSelectedEvent() {
    final String path = "org:kie:1.0";
    final GAV gav = new GAV(path);
    when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav);
    when(view.getContainerName()).thenReturn("containerName");
    when(view.getContainerAlias()).thenReturn("containerAlias");
    when(view.getGroupId()).thenReturn(gav.getGroupId());
    when(view.getArtifactId()).thenReturn(gav.getArtifactId());
    when(view.getVersion()).thenReturn(gav.getVersion());
    presenter.asWidget();
    presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path));
    verify(m2RepoService).loadGAVFromJar(path);
    verify(view).setGroupId(gav.getGroupId());
    verify(view).setArtifactId(gav.getArtifactId());
    verify(view).setVersion(gav.getVersion());
    verify(wizardPageStatusChangeEvent).fire(any(WizardPageStatusChangeEvent.class));
    final ContainerSpec containerSpec = presenter.buildContainerSpec("templateId", Collections.<Capability, ContainerConfig>emptyMap());
    assertEquals(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()), containerSpec.getReleasedId());
    assertEquals(KieContainerStatus.STOPPED, containerSpec.getStatus());
    assertEquals("containerAlias", containerSpec.getContainerName());
    assertEquals("containerName", containerSpec.getId());
}
Also used : ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Matchers.anyString(org.mockito.Matchers.anyString) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) ReleaseId(org.kie.server.api.model.ReleaseId) GAV(org.guvnor.common.services.project.model.GAV) DependencyPathSelectedEvent(org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 DependencyPathSelectedEvent (org.kie.workbench.common.screens.server.management.client.events.DependencyPathSelectedEvent)5 GAV (org.guvnor.common.services.project.model.GAV)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)2 ReleaseId (org.kie.server.api.model.ReleaseId)1 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)1 WizardPageStatusChangeEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent)1