Search in sources :

Example 1 with SnapshotDeployment

use of org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment in project kie-wb-common by kiegroup.

the class SnapshotBuildAndDeployExecutorTest method testBuildAndDeployWithMultipleTemplatesWithPreviousDeployment.

@Test
public void testBuildAndDeployWithMultipleTemplatesWithPreviousDeployment() {
    final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
    serverTemplate.setMode(KieServerMode.DEVELOPMENT);
    final ServerTemplate serverTemplate2 = new ServerTemplate(SERVER_TEMPLATE_ID2, SERVER_TEMPLATE_NAME2);
    serverTemplate2.setMode(KieServerMode.DEVELOPMENT);
    ContainerSpec spec = mock(ContainerSpec.class);
    when(spec.getId()).thenReturn(context.getContainerId());
    serverTemplate2.addContainerSpec(spec);
    when(settings.getDeployment(anyString(), anyString())).thenReturn(Optional.of(new SnapshotDeployment(GROUP, ARTIFACT, SERVER_TEMPLATE_ID2)));
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Arrays.asList(serverTemplate, serverTemplate2)));
    runner.run(context);
    verify(buildDialog).startBuild();
    verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).updateContainerSpec(eq(SERVER_TEMPLATE_ID2), containerSpecArgumentCaptor.capture());
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessfulAndContainerUpdated(), NotificationEvent.NotificationType.SUCCESS);
    verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
    verify(buildDialog, atLeastOnce()).stopBuild();
    verify(deploymentPopup, never()).show(any());
}
Also used : SnapshotDeployment(org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 2 with SnapshotDeployment

use of org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment in project kie-wb-common by kiegroup.

the class SnapshotRedeployExecutorTest method testRedeployWithMultipleTemplatesWithPreviousDeployment.

@Test
public void testRedeployWithMultipleTemplatesWithPreviousDeployment() {
    final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
    serverTemplate.setMode(KieServerMode.DEVELOPMENT);
    final ServerTemplate serverTemplate2 = new ServerTemplate(SERVER_TEMPLATE_ID2, SERVER_TEMPLATE_NAME2);
    serverTemplate2.setMode(KieServerMode.DEVELOPMENT);
    ContainerSpec spec = mock(ContainerSpec.class);
    when(spec.getId()).thenReturn(context.getContainerId());
    serverTemplate2.addContainerSpec(spec);
    when(settings.getDeployment(anyString(), anyString())).thenReturn(Optional.of(new SnapshotDeployment(GROUP, ARTIFACT, SERVER_TEMPLATE_ID2)));
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Arrays.asList(serverTemplate, serverTemplate2)));
    runner.run(context);
    verify(buildDialog).startBuild();
    verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).updateContainerSpec(eq(SERVER_TEMPLATE_ID2), eq(context.getContainerId()), containerSpecArgumentCaptor.capture(), eq(true));
    ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessfulAndContainerUpdated(), NotificationEvent.NotificationType.SUCCESS);
    verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
    verify(buildDialog, atLeastOnce()).stopBuild();
    verify(deploymentPopup, never()).show(any());
}
Also used : SnapshotDeployment(org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) AbstractBuildAndDeployExecutorTest(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.deploy.AbstractBuildAndDeployExecutorTest) Test(org.junit.Test)

Example 3 with SnapshotDeployment

use of org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment in project kie-wb-common by kiegroup.

the class SnapshotBuildAndDeployExecutor method buildDeployWithMultipleServerTemplates.

@Override
void buildDeployWithMultipleServerTemplates(BuildExecutionContext context, List<ServerTemplate> serverTemplates) {
    GAV gav = context.getModule().getPom().getGav();
    Optional<SnapshotDeployment> optional = settings.getDeployment(gav.getGroupId(), gav.getArtifactId());
    if (optional.isPresent()) {
        SnapshotDeployment previousDeployment = optional.get();
        Optional<ServerTemplate> serverOptional = serverTemplates.stream().filter(s -> s.getId().equals(previousDeployment.getServer())).findFirst();
        if (serverOptional.isPresent()) {
            buildDeployWithOneServerTemplate(context, serverOptional.get());
            return;
        }
    }
    context.setServerTemplate(serverTemplates.get(0));
    deploymentPopup.show(new DefaultDeploymentPopupDriver(context, DeploymentPopup.Mode.MULTIPLE_SERVER_FORCED, () -> serverTemplates, () -> buildDeployWithOneServerTemplate(context, context.getServerTemplate()), () -> finish()));
}
Also used : Event(javax.enterprise.event.Event) SnapshotDeploymentSettings(org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeploymentSettings) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) DefaultDeploymentPopupDriver(org.kie.workbench.common.screens.projecteditor.client.editor.DefaultDeploymentPopupDriver) GAV(org.guvnor.common.services.project.model.GAV) BuildDialog(org.kie.workbench.common.screens.projecteditor.client.build.exec.dialog.BuildDialog) KieServerMode(org.kie.server.api.model.KieServerMode) SnapshotDeployment(org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) BuildExecutionContext(org.kie.workbench.common.screens.projecteditor.client.build.exec.BuildExecutionContext) DeploymentPopup(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentPopup) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) Message(org.jboss.errai.bus.client.api.messaging.Message) Caller(org.jboss.errai.common.client.api.Caller) SnapshotContextValidator(org.kie.workbench.common.screens.projecteditor.client.build.exec.impl.executors.validators.SnapshotContextValidator) Optional(java.util.Optional) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) BuildService(org.guvnor.common.services.project.builder.service.BuildService) SnapshotDeployment(org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) DefaultDeploymentPopupDriver(org.kie.workbench.common.screens.projecteditor.client.editor.DefaultDeploymentPopupDriver) GAV(org.guvnor.common.services.project.model.GAV)

Aggregations

ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)3 SnapshotDeployment (org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeployment)3 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 Test (org.junit.Test)2 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)2 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)2 List (java.util.List)1 Optional (java.util.Optional)1 Event (javax.enterprise.event.Event)1 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)1 BuildService (org.guvnor.common.services.project.builder.service.BuildService)1 GAV (org.guvnor.common.services.project.model.GAV)1 DeploymentMode (org.guvnor.common.services.project.service.DeploymentMode)1 Message (org.jboss.errai.bus.client.api.messaging.Message)1 Caller (org.jboss.errai.common.client.api.Caller)1 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 KieServerMode (org.kie.server.api.model.KieServerMode)1 SnapshotDeploymentSettings (org.kie.workbench.common.screens.projecteditor.build.exec.SnapshotDeploymentSettings)1 BuildExecutionContext (org.kie.workbench.common.screens.projecteditor.client.build.exec.BuildExecutionContext)1