Search in sources :

Example 16 with ContainerSpec

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

the class BuildExecutor method saveContainerSpec.

private void saveContainerSpec(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final Boolean startContainer, final Map<String, String> parameters) {
    if (containerId != null && serverTemplate != null && serverTemplate.getId() != null) {
        final ContainerSpec containerSpec = makeContainerSpec(containerId, containerAlias, serverTemplate, parameters);
        specManagementService.call(aVoid -> {
            notificationEvent.fire(new NotificationEvent(ProjectEditorResources.CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS));
            if (startContainer) {
                startContainer(containerSpec);
            }
        }).saveContainerSpec(serverTemplate.getId(), containerSpec);
    }
}
Also used : UnexpectedTypeException(javax.validation.UnexpectedTypeException) Arrays(java.util.Arrays) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HasBusyIndicator(org.uberfire.ext.widgets.common.client.common.HasBusyIndicator) GAV(org.guvnor.common.services.project.model.GAV) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Inject(javax.inject.Inject) ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) MergeMode(org.kie.workbench.common.screens.server.management.model.MergeMode) POM(org.guvnor.common.services.project.model.POM) CommandWithThrowableDrivenErrorCallback(org.kie.workbench.common.widgets.client.callbacks.CommandWithThrowableDrivenErrorCallback) Capability(org.kie.server.controller.api.model.spec.Capability) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) ProjectEditorResources(org.kie.workbench.common.screens.projecteditor.client.resources.ProjectEditorResources) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) Map(java.util.Map) Module(org.guvnor.common.services.project.model.Module) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) KieContainerStatus(org.kie.server.api.model.KieContainerStatus) BuildService(org.guvnor.common.services.project.builder.service.BuildService) Command(org.uberfire.mvp.Command) Event(javax.enterprise.event.Event) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) Collection(java.util.Collection) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Collectors(java.util.stream.Collectors) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) KieScannerStatus(org.kie.server.api.model.KieScannerStatus) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) Message(org.jboss.errai.bus.client.api.messaging.Message) GAVAlreadyExistsException(org.guvnor.common.services.project.service.GAVAlreadyExistsException) ConflictingRepositoriesPopup(org.guvnor.common.services.project.client.repositories.ConflictingRepositoriesPopup) RuntimeStrategy(org.kie.workbench.common.screens.server.management.model.RuntimeStrategy) Caller(org.jboss.errai.common.client.api.Caller) DeploymentScreenPopupViewImpl(org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl) ReleaseId(org.kie.server.api.model.ReleaseId) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 17 with ContainerSpec

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

the class BuildExecutor method makeContainerSpec.

private ContainerSpec makeContainerSpec(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final Map<String, String> parameters) {
    final ReleaseId releaseId = makeReleaseId();
    final KieContainerStatus status = KieContainerStatus.STOPPED;
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getId());
    return new ContainerSpec(containerId, containerAlias, serverTemplateKey, releaseId, status, makeConfigs(serverTemplate, parameters));
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ReleaseId(org.kie.server.api.model.ReleaseId) KieContainerStatus(org.kie.server.api.model.KieContainerStatus)

Example 18 with ContainerSpec

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

the class BuildExecutorTest method testBuildAndDeployCommandSingleServerTemplate.

@Test
public void testBuildAndDeployCommandSingleServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate("id", "name");
    when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Collections.singletonList(serverTemplate)));
    buildExecutor.triggerBuildAndDeploy();
    ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
    verify(specManagementServiceMock).saveContainerSpec(eq(serverTemplate.getId()), containerSpecArgumentCaptor.capture());
    final ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
    assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
    verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS);
    verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
    verifyBusyShowHideAnyString(1, 1);
}
Also used : 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 19 with ContainerSpec

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

the class DeploymentPopupBuilderTest method serverTemplate.

private ServerTemplate serverTemplate(final String id, final String... containerNames) {
    final ServerTemplate serverTemplate = mock(ServerTemplate.class);
    final ArrayList<ContainerSpec> containersSpec = new ArrayList<ContainerSpec>() {

        {
            for (final String containerName : containerNames) {
                add(containerSpec(containerName));
            }
        }
    };
    doReturn(id).when(serverTemplate).getId();
    doReturn(containersSpec).when(serverTemplate).getContainersSpec();
    return serverTemplate;
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList)

Example 20 with ContainerSpec

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

the class SpecManagementServiceCDITest method testValidContainerIdWhenContainerIdIsValidInTheSecondAttempt.

@Test
public void testValidContainerIdWhenContainerIdIsValidInTheSecondAttempt() {
    final SpecManagementServiceCDI service = spy(new SpecManagementServiceCDI());
    final ServerTemplate template = mock(ServerTemplate.class);
    final ContainerSpec containerSpec = mock(ContainerSpec.class);
    when(template.getContainerSpec("org.jbpm:Evaluation:1.0")).thenReturn(containerSpec);
    when(template.getContainerSpec("org.jbpm:Evaluation:1.0-2")).thenReturn(null);
    doReturn(template).when(service).getServerTemplate("templateId");
    final String containerId = service.validContainerId("templateId", "org.jbpm:Evaluation:1.0");
    assertEquals(containerId, "org.jbpm:Evaluation:1.0-2");
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Test(org.junit.Test)

Aggregations

ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)33 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)22 Test (org.junit.Test)20 ReleaseId (org.kie.server.api.model.ReleaseId)13 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)10 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)8 Container (org.kie.server.controller.api.model.runtime.Container)7 Capability (org.kie.server.controller.api.model.spec.Capability)7 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)7 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)6 HashMap (java.util.HashMap)5 Path (org.uberfire.java.nio.file.Path)5 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)4 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GAV (org.guvnor.common.services.project.model.GAV)3 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)3