Java Code Examples for org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl#setAccount()

The following examples show how to use org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl#setAccount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkspaceDaoTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
public static WorkspaceImpl createWorkspaceFromConfig(
    String id, AccountImpl account, String name) {
  final WorkspaceConfigImpl wCfg = createWorkspaceConfig(name);
  // Workspace
  final WorkspaceImpl workspace = new WorkspaceImpl();
  workspace.setId(id);
  workspace.setAccount(account);
  wCfg.setName(name);
  workspace.setConfig(wCfg);
  workspace.setAttributes(
      new HashMap<>(
          ImmutableMap.of(
              "attr1", "value1",
              "attr2", "value2",
              "attr3", "value3")));
  workspace.setConfig(wCfg);
  return workspace;
}
 
Example 2
Source File: WorkspaceDaoTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
public static WorkspaceImpl createWorkspaceFromDevfile(
    String id, AccountImpl account, String name) {
  final DevfileImpl devfile = createDevfile(name);
  // Workspace
  final WorkspaceImpl workspace = new WorkspaceImpl();
  workspace.setId(id);
  workspace.setAccount(account);
  workspace.setDevfile(devfile);
  workspace.setAttributes(
      new HashMap<>(
          ImmutableMap.of(
              "attr1", "value1",
              "attr2", "value2",
              "attr3", "value3")));
  return workspace;
}
 
Example 3
Source File: WorkspaceActivityDaoTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
private static WorkspaceImpl createWorkspace(String id, AccountImpl account, String name) {
  final WorkspaceConfigImpl wCfg = createWorkspaceConfig(name);
  // Workspace
  final WorkspaceImpl workspace = new WorkspaceImpl();
  workspace.setId(id);
  workspace.setAccount(account);
  wCfg.setName(name);
  workspace.setConfig(wCfg);
  return workspace;
}
 
Example 4
Source File: WorkspaceDaoTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void shouldCreateWorkspaceWithNameWhichDoesNotExistInGivenNamespace() throws Exception {
  final WorkspaceImpl workspace = workspaces[0];
  final WorkspaceImpl workspace2 = workspaces[3];

  final WorkspaceImpl newWorkspace =
      createWorkspaceFromConfig(
          "new-id", workspace.getAccount(), workspace2.getConfig().getName());
  final WorkspaceImpl expected = new WorkspaceImpl(newWorkspace, newWorkspace.getAccount());
  expected.setAccount(newWorkspace.getAccount());
  assertEquals(workspaceDao.create(newWorkspace), expected);
}
 
Example 5
Source File: WorkspaceDaoTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test(
    expectedExceptions = ConflictException.class,
    expectedExceptionsMessageRegExp =
        "Workspace with name 'name-3' in namespace 'accountName1' already exists")
public void shouldNotUpdateWorkspaceWithReservedNameFromDevfile() throws Exception {
  final WorkspaceImpl workspace1 = workspaces[3];
  final WorkspaceImpl workspace2 = workspaces[DEVFILE_WORKSPACE_INDEX];

  workspace2.getDevfile().setName(workspace1.getConfig().getName());
  workspace2.setAccount(workspace1.getAccount());

  workspaceDao.update(workspace2);
}
 
Example 6
Source File: WorkspaceRuntimesTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test(
    expectedExceptions = NotFoundException.class,
    expectedExceptionsMessageRegExp =
        "Workspace 'account:ws' doesn't contain environment 'non-existing'")
public void throwsNotFoundExceptionWhenStartWorkspaceWithNotExistingEnv() throws Exception {
  final WorkspaceImpl workspace = new WorkspaceImpl();
  WorkspaceConfigImpl config = new WorkspaceConfigImpl();
  workspace.setAccount(new AccountImpl("acc123", "account", "any"));
  workspace.setConfig(config);
  config.setName("ws");
  config.getEnvironments().put("default", new EnvironmentImpl());

  runtimes.validate(workspace, "non-existing");
}
 
Example 7
Source File: WorkspaceDaoTest.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@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()));
}