Search in sources :

Example 66 with CommandImpl

use of org.eclipse.che.api.workspace.server.model.impl.CommandImpl in project che-server by eclipse-che.

the class PreviewUrlLinksVariableGeneratorTest method shouldDoNothingWhenNoCommandWithPreviewurlAttribute.

@Test
public void shouldDoNothingWhenNoCommandWithPreviewurlAttribute() {
    CommandImpl command = new CommandImpl("a", "a", "a", new PreviewUrlImpl(123, null), Collections.emptyMap());
    WorkspaceImpl w = createWorkspaceWithCommands(singletonList(command));
    assertTrue(generator.genLinksMapAndUpdateCommands(w, uriBuilder).isEmpty());
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) PreviewUrlImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl) Test(org.testng.annotations.Test)

Example 67 with CommandImpl

use of org.eclipse.che.api.workspace.server.model.impl.CommandImpl in project che-server by eclipse-che.

the class PreviewUrlLinksVariableGeneratorTest method shouldGetHttpsWhenUriBuilderHasHttps.

@Test
public void shouldGetHttpsWhenUriBuilderHasHttps() {
    UriBuilder httpsUriBuilder = UriBuilder.fromUri("https://host/path");
    Map<String, String> commandAttrs = new HashMap<>();
    commandAttrs.put(Command.PREVIEW_URL_ATTRIBUTE, "preview_url_host");
    CommandImpl command = new CommandImpl("run command", "a", "a", new PreviewUrlImpl(123, null), commandAttrs);
    Map<String, String> linkMap = generator.genLinksMapAndUpdateCommands(createWorkspaceWithCommands(singletonList(command)), httpsUriBuilder);
    assertTrue(linkMap.values().iterator().next().startsWith("https://"));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) HashMap(java.util.HashMap) PreviewUrlImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl) UriBuilder(jakarta.ws.rs.core.UriBuilder) Test(org.testng.annotations.Test)

Example 68 with CommandImpl

use of org.eclipse.che.api.workspace.server.model.impl.CommandImpl in project che-server by eclipse-che.

the class KubernetesRuntimeStateCacheTest method shouldThrowExceptionUpdateCommands.

@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Runtime state for workspace with id 'non-existent-ws' was not found")
public void shouldThrowExceptionUpdateCommands() throws Exception {
    // given
    CommandImpl newCommand = new CommandImpl("new", "build", "custom");
    // when
    runtimesStatesCache.updateCommands(new RuntimeIdentityImpl("non-existent-ws", "defEnv", "acc1", "infraNamespace"), singletonList(newCommand));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) RuntimeIdentityImpl(org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl) Test(org.testng.annotations.Test)

Example 69 with CommandImpl

use of org.eclipse.che.api.workspace.server.model.impl.CommandImpl in project che-server by eclipse-che.

the class TestObjectsFactory method createCommand.

public static CommandImpl createCommand() {
    CommandImpl cmd = new CommandImpl(generate("command", 5), "echo " + generate("command", 5), "CUSTOM");
    cmd.getAttributes().put("attr1", "val1");
    cmd.getAttributes().put("attr2", "val2");
    return cmd;
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl)

Example 70 with CommandImpl

use of org.eclipse.che.api.workspace.server.model.impl.CommandImpl in project che-server by eclipse-che.

the class PluginComponentToWorkspaceApplierTest method shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry.

@Test
public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() throws Exception {
    // given
    ComponentImpl superPluginComponent = new ComponentImpl();
    superPluginComponent.setAlias("super-plugin");
    superPluginComponent.setId("https://custom-plugin.registry/plugins/#eclipse/super-plugin/0.0.1");
    superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
    WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
    CommandImpl command = new CommandImpl();
    command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "super-plugin");
    workspaceConfig.getCommands().add(command);
    // when
    pluginComponentApplier.apply(workspaceConfig, superPluginComponent, null);
    // then
    assertEquals(workspaceConfig.getCommands().get(0).getAttributes().get(PLUGIN_ATTRIBUTE), "eclipse/super-plugin/0.0.1");
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Aggregations

CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)106 Test (org.testng.annotations.Test)80 PreviewUrlImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl)40 ArrayList (java.util.ArrayList)32 Service (io.fabric8.kubernetes.api.model.Service)30 HashMap (java.util.HashMap)30 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)26 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)24 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)24 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)20 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)18 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)18 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)18 OpenShiftEnvironment (org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment)16 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)14 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)14 List (java.util.List)12 IngressBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)10 ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)10 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)9