Search in sources :

Example 41 with CommandImpl

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

the class EditorComponentToWorkspaceApplierTest method shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry.

@Test
public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() throws Exception {
    // given
    ComponentImpl superPluginComponent = new ComponentImpl();
    superPluginComponent.setAlias("editor");
    superPluginComponent.setId("https://custom-plugin.registry/plugins#eclipse/super-editor/0.0.1");
    superPluginComponent.setType(EDITOR_COMPONENT_TYPE);
    WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
    CommandImpl command = new CommandImpl();
    command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "editor");
    workspaceConfig.getCommands().add(command);
    // when
    editorComponentApplier.apply(workspaceConfig, superPluginComponent, null);
    // then
    assertEquals(workspaceConfig.getCommands().get(0).getAttributes().get(PLUGIN_ATTRIBUTE), "eclipse/super-editor/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)

Example 42 with CommandImpl

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

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)

Example 43 with CommandImpl

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

the class PreviewUrlLinksVariableGeneratorTest method variableNamesForTwoCommandsWithSimilarNameMustBeDifferent.

@Test
public void variableNamesForTwoCommandsWithSimilarNameMustBeDifferent() {
    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);
    CommandImpl command2 = new CommandImpl(command);
    command2.setName("runcommand");
    WorkspaceImpl w = createWorkspaceWithCommands(Arrays.asList(command, command2));
    Map<String, String> linkMap = generator.genLinksMapAndUpdateCommands(w, uriBuilder);
    assertEquals(linkMap.size(), 2);
    List<? extends Command> commandsAfter = w.getRuntime().getCommands();
    assertNotEquals(commandsAfter.get(1).getAttributes().get(Command.PREVIEW_URL_ATTRIBUTE), commandsAfter.get(0).getAttributes().get(Command.PREVIEW_URL_ATTRIBUTE));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) HashMap(java.util.HashMap) PreviewUrlImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl) Test(org.testng.annotations.Test)

Example 44 with CommandImpl

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

the class PreviewUrlLinksVariableGeneratorTest method shouldAppendPathWhenDefinedInPreviewUrl.

@Test
public void shouldAppendPathWhenDefinedInPreviewUrl() {
    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, "testpath"), commandAttrs);
    WorkspaceImpl workspace = createWorkspaceWithCommands(singletonList(command));
    Map<String, String> linkMap = generator.genLinksMapAndUpdateCommands(workspace, uriBuilder);
    assertTrue(linkMap.values().iterator().next().endsWith("preview_url_host"));
    String linkKey = linkMap.keySet().iterator().next();
    assertEquals(workspace.getRuntime().getCommands().get(0).getAttributes().get(Command.PREVIEW_URL_ATTRIBUTE), "${" + linkKey + "}testpath");
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) HashMap(java.util.HashMap) PreviewUrlImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl) Test(org.testng.annotations.Test)

Example 45 with CommandImpl

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

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)

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