use of org.kie.server.controller.api.model.spec.ContainerSpec 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();
}
use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.
the class NewContainerFormPresenterTest method testNewContainerStarted.
@Test
public void testNewContainerStarted() {
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());
when(view.isStartContainer()).thenReturn(true);
presenter.asWidget();
final ContainerSpec containerSpec = presenter.buildContainerSpec("templateId", Collections.<Capability, ContainerConfig>emptyMap());
assertEquals(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()), containerSpec.getReleasedId());
assertEquals(KieContainerStatus.STARTED, containerSpec.getStatus());
assertEquals("containerAlias", containerSpec.getContainerName());
assertEquals("containerName", containerSpec.getId());
}
use of org.kie.server.controller.api.model.spec.ContainerSpec 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());
}
Aggregations