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");
}
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");
}
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));
}
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");
}
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://"));
}
Aggregations