use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class PluginComponentToWorkspaceApplierTest method shouldProvisionPluginWorkspaceAttributeWithReferenceDuringChePluginComponentApplying.
@Test
public void shouldProvisionPluginWorkspaceAttributeWithReferenceDuringChePluginComponentApplying() throws Exception {
String superPluginId = "eclipse/super-plugin/0.0.1";
String reference = "https://myregistry.com/infolder/meta.yaml";
String meta = "apiVersion: v2\n" + "publisher: eclipse\n" + "name: super-plugin\n" + "version: 0.0.1\n" + "type: Che Plugin";
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId(superPluginId);
superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
superPluginComponent.setMemoryLimit("1234M");
when(fileContentProvider.fetchContent(anyString())).thenReturn(meta);
ComponentImpl customPluginComponent = new ComponentImpl();
customPluginComponent.setAlias("custom");
customPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
customPluginComponent.setReference(reference);
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
// when
pluginComponentApplier.apply(workspaceConfig, superPluginComponent, fileContentProvider);
pluginComponentApplier.apply(workspaceConfig, customPluginComponent, fileContentProvider);
// then
String workspaceTooling = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE);
assertTrue(workspaceTooling.matches("(.+/.+/.+),(https://.+/.+/.+)"));
assertTrue(workspaceTooling.contains(superPluginId));
assertTrue(workspaceTooling.contains(reference));
assertEquals(customPluginComponent.getId(), "eclipse/super-plugin/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 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.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class PluginComponentToWorkspaceApplierTest method shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApplying.
@Test
public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApplying() throws Exception {
String superPluginId = "eclipse/super-plugin/0.0.1";
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId(superPluginId);
superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
superPluginComponent.setMemoryLimit("1234M");
superPluginComponent.getPreferences().put("java-home", "/home/user/jdk11");
ComponentImpl customPluginComponent = new ComponentImpl();
customPluginComponent.setAlias("custom");
customPluginComponent.setId("publisher1/custom-plugin/v1");
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("publisher1/custom-plugin/v1"));
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class DevfileIntegrityValidatorTest method shouldRequireAliasWhenDockerImageComponentsHaveSameImage.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "There are multiple components 'dockerimage:latest' of type 'dockerimage' that cannot be" + " uniquely identified. Please add aliases that would distinguish the components.")
public void shouldRequireAliasWhenDockerImageComponentsHaveSameImage() throws Exception {
// given
DevfileImpl devfile = new DevfileImpl(initialDevfile);
ComponentImpl docker1 = new ComponentImpl();
docker1.setType(DOCKERIMAGE_COMPONENT_TYPE);
docker1.setImage("dockerimage:latest");
ComponentImpl docker2 = new ComponentImpl();
docker2.setType(DOCKERIMAGE_COMPONENT_TYPE);
docker2.setImage("dockerimage:latest");
devfile.getComponents().add(docker1);
devfile.getComponents().add(docker2);
// when
integrityValidator.validateDevfile(devfile);
// then
// exception is thrown
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project devspaces-images by redhat-developer.
the class DevfileIntegrityValidatorTest method shouldThrowExceptionOnDuplicateEnvironmentVariable.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Duplicate environment variable 'foo' found in component 'test1'")
public void shouldThrowExceptionOnDuplicateEnvironmentVariable() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
ComponentImpl k8s1 = new ComponentImpl();
k8s1.setType(OPENSHIFT_COMPONENT_TYPE);
k8s1.setAlias("test1");
k8s1.getEnv().add(new EnvImpl("foo", "bar"));
k8s1.getEnv().add(new EnvImpl("foo", "baz"));
broken.getComponents().add(k8s1);
// when
integrityValidator.validateDevfile(broken);
}
Aggregations