use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class DefaultEditorProvisionerTest method shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStartWithDefaultId.
@Test
public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStartWithDefaultId() throws Exception {
// given
provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
DevfileImpl devfile = new DevfileImpl();
ComponentImpl editorWithNameSimilarToDefault = new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + EDITOR_NAME + "-dev/dev-version");
devfile.getComponents().add(editorWithNameSimilarToDefault);
// when
provisioner.apply(devfile, fileContentProvider);
// then
List<ComponentImpl> components = devfile.getComponents();
assertEquals(components.size(), 1);
assertTrue(components.contains(editorWithNameSimilarToDefault));
assertNull(findById(components, EDITOR_NAME));
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class EditorComponentToWorkspaceApplierTest method shouldProvisionWorkspaceEditorAttributeWithReferenceDuringCheEditorComponentApplying.
@Test
public void shouldProvisionWorkspaceEditorAttributeWithReferenceDuringCheEditorComponentApplying() throws Exception {
String reference = "https://myregistry.com/infolder/meta.yaml";
String meta = "apiVersion: v2\n" + "publisher: eclipse\n" + "name: super-editor\n" + "version: 0.0.1\n" + "type: Che Editor";
// given
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
ComponentImpl editorComponent = new ComponentImpl();
editorComponent.setType(EDITOR_COMPONENT_TYPE);
editorComponent.setAlias("editor1");
editorComponent.setReference(reference);
editorComponent.setMemoryLimit("12345M");
when(fileContentProvider.fetchContent(anyString())).thenReturn(meta);
// when
editorComponentApplier.apply(workspaceConfig, editorComponent, fileContentProvider);
// then
assertEquals(workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE), reference);
assertEquals(editorComponent.getId(), "eclipse/super-editor/0.0.1");
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class EditorComponentToWorkspaceApplierTest method shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApplying.
@Test
public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApplying() throws Exception {
String editorId = "eclipse/super-editor/0.0.1";
// given
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
ComponentImpl editorComponent = new ComponentImpl();
editorComponent.setType(EDITOR_COMPONENT_TYPE);
editorComponent.setAlias("editor");
editorComponent.setId(editorId);
editorComponent.setMemoryLimit("12345M");
// when
editorComponentApplier.apply(workspaceConfig, editorComponent, null);
// then
assertEquals(workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE), editorId);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl 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.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class PluginComponentToWorkspaceApplierTest method shouldProvisionPluginWorkspaceAttributeWithCustomRegistryDuringChePluginComponentApplying.
@Test
public void shouldProvisionPluginWorkspaceAttributeWithCustomRegistryDuringChePluginComponentApplying() throws Exception {
String superPluginId = "eclipse/super-plugin/0.0.1";
String registryUrl = "https://myregistry.com/infolder/";
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId(superPluginId);
superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
superPluginComponent.setMemoryLimit("1234M");
ComponentImpl customPluginComponent = new ComponentImpl();
customPluginComponent.setAlias("custom");
customPluginComponent.setId("publisher1/custom-plugin/v1");
customPluginComponent.setRegistryUrl(registryUrl);
customPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
// when
pluginComponentApplier.apply(workspaceConfig, superPluginComponent, null);
pluginComponentApplier.apply(workspaceConfig, customPluginComponent, null);
// then
String workspaceTooling = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE);
assertTrue(workspaceTooling.matches("(.+/.+/.+),(.+/.+/.+)"));
assertTrue(workspaceTooling.contains(superPluginId));
assertTrue(workspaceTooling.contains(registryUrl + "#" + "publisher1/custom-plugin/v1"));
}
Aggregations