use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project che-server by eclipse-che.
the class PluginComponentToWorkspaceApplierTest method shouldProvisionPluginCommandAttributesDuringChePluginComponentApplying.
@Test
public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplying() throws Exception {
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId("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 che-server by eclipse-che.
the class DevfileIntegrityValidatorTest method shouldThrowExceptionOnMultipleEditors.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Multiple editor components found: 'eclipse/che-theia/0.0.3', 'editor-2'")
public void shouldThrowExceptionOnMultipleEditors() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
ComponentImpl component = new ComponentImpl();
component.setAlias("editor-2");
component.setType(EDITOR_COMPONENT_TYPE);
broken.getComponents().add(component);
// when
integrityValidator.validateDevfile(broken);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project che-server by eclipse-che.
the class WorkspaceDaoTest method shouldUpdateWorkspaceWithDevfile.
@Test(dependsOnMethods = "shouldGetWorkspaceById")
public void shouldUpdateWorkspaceWithDevfile() throws Exception {
final WorkspaceImpl workspace = new WorkspaceImpl(workspaces[DEVFILE_WORKSPACE_INDEX], workspaces[DEVFILE_WORKSPACE_INDEX].getAccount());
// Remove an existing project configuration from workspace
workspace.getDevfile().getProjects().remove(1);
final SourceImpl source3 = new SourceImpl("type3", "http://location", "branch3", "point3", "tag3", "commit3", "sparseCheckoutDir3");
ProjectImpl newProject = new ProjectImpl("project3", source3, "path3");
workspace.getDevfile().getProjects().add(newProject);
// Update an existing project configuration
final ProjectImpl projectCfg = workspace.getDevfile().getProjects().get(0);
projectCfg.getSource().setLocation("new-location");
projectCfg.getSource().setType("new-type");
projectCfg.getSource().setBranch("new-branch");
projectCfg.getSource().setCommitId("new-commit");
projectCfg.getSource().setTag("new-tag");
projectCfg.getSource().setStartPoint("new-point");
projectCfg.getSource().setSparseCheckoutDir("new-sparse-checkout-dir");
// Remove an existing command
workspace.getDevfile().getCommands().remove(1);
ActionImpl action3 = new ActionImpl("exec3", "component3", "run.sh", "/home/user/3", null, null);
ActionImpl action4 = new ActionImpl("exec4", "component4", "run.sh", "/home/user/4", null, null);
// Add a new command
final org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl newCmd = new org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl("command-3", singletonList(action3), singletonMap("attr3", "value3"), null);
workspace.getDevfile().getCommands().add(newCmd);
// Update an existing command
final org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl command = workspace.getDevfile().getCommands().get(0);
command.setName("new-name");
command.setActions(asList(action4));
command.getAttributes().clear();
workspace.getDevfile().getComponents().remove(1);
EntrypointImpl entrypoint3 = new EntrypointImpl("parentName", singletonMap("parent3", "selector3"), "containerName3", asList("command3", "command5"), asList("arg3", "arg5"));
org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl volume3 = new org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl("name3", "path3");
EnvImpl env3 = new EnvImpl("name3", "value3");
EndpointImpl endpoint3 = new EndpointImpl("name3", 3333, singletonMap("key3", "value3"));
ComponentImpl component3 = workspace.getDevfile().getComponents().get(0);
new ComponentImpl("kubernetes", "component3", "eclipse/che-theia/0.0.1", ImmutableMap.of("java.home", "/opt/jdk11"), "https://mysite.com/registry/somepath", "/dev.yaml", null, ImmutableMap.of("app.kubernetes.io/component", "webapp"), singletonList(entrypoint3), "image", "1256G", "123G", "2", "1", false, false, singletonList("command"), singletonList("arg"), singletonList(volume3), singletonList(env3), singletonList(endpoint3));
component3.setSelector(singletonMap("key3", "value3"));
// Update workspace object
workspace.setAccount(new AccountImpl("accId", "new-namespace", "test"));
workspace.getAttributes().clear();
workspaceDao.update(workspace);
assertEquals(workspaceDao.get(workspace.getId()), new WorkspaceImpl(workspace, workspace.getAccount()));
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project che-server by eclipse-che.
the class DevfileIntegrityValidatorTest method shouldRequireAliasWhenOpenshiftComponentsHaveNoReference.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "There are multiple components 'openshift' of type 'openshift' that cannot be" + " uniquely identified. Please add aliases that would distinguish the components.")
public void shouldRequireAliasWhenOpenshiftComponentsHaveNoReference() throws Exception {
// given
DevfileImpl devfile = new DevfileImpl(initialDevfile);
ComponentImpl k8s1 = new ComponentImpl();
k8s1.setType(OPENSHIFT_COMPONENT_TYPE);
ComponentImpl k8s2 = new ComponentImpl();
k8s2.setType(OPENSHIFT_COMPONENT_TYPE);
devfile.getComponents().add(k8s1);
devfile.getComponents().add(k8s2);
// when
integrityValidator.validateDevfile(devfile);
// then
// exception is thrown
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl in project che-server by eclipse-che.
the class DevfileIntegrityValidatorTest method shouldThrowExceptionOnDuplicateComponentAlias.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Duplicate component alias found:'mvn-stack'")
public void shouldThrowExceptionOnDuplicateComponentAlias() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
ComponentImpl component = new ComponentImpl();
component.setAlias(initialDevfile.getComponents().get(0).getAlias());
broken.getComponents().add(component);
// when
integrityValidator.validateDevfile(broken);
}
Aggregations