Search in sources :

Example 6 with WorkspaceConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl in project che by eclipse.

the class LocalWorkspaceFolderPathProviderTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    WorkspaceImpl workspace = mock(WorkspaceImpl.class);
    WorkspaceConfigImpl workspaceConfig = mock(WorkspaceConfigImpl.class);
    when(workspaceManager.getWorkspace(WS_ID)).thenReturn(workspace);
    when(workspace.getConfig()).thenReturn(workspaceConfig);
    when(workspaceConfig.getName()).thenReturn(WS_NAME);
    Path tempDirectory = Files.createTempDirectory(getClass().getSimpleName());
    workspacesRoot = tempDirectory.toString();
    workspacesRootFile = tempDirectory.toFile();
    singleFolderForAllWorkspaces = Paths.get(workspacesRoot, "singleFolderForAllWorkspaces").toString();
    oldWorkspacesRoot = Paths.get(workspacesRoot, "oldWorkspacesRoot").toString();
}
Also used : Path(java.nio.file.Path) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with WorkspaceConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl in project che by eclipse.

the class StackServiceTest method setUp.

@BeforeMethod
public void setUp() throws NoSuchFieldException, IllegalAccessException {
    byte[] fileContent = STACK_ID.getBytes();
    stackIcon = new StackIcon(ICON_MEDIA_TYPE, "image/svg+xml", fileContent);
    componentsImpl = singletonList(new StackComponentImpl(COMPONENT_NAME, COMPONENT_VERSION));
    stackSourceImpl = new StackSourceImpl(SOURCE_TYPE, SOURCE_ORIGIN);
    CommandImpl command = new CommandImpl(COMMAND_NAME, COMMAND_LINE, COMMAND_TYPE);
    EnvironmentImpl environment = new EnvironmentImpl(null, null);
    WorkspaceConfigImpl workspaceConfig = WorkspaceConfigImpl.builder().setName(WORKSPACE_CONFIG_NAME).setDefaultEnv(DEF_ENVIRONMENT_NAME).setCommands(singletonList(command)).setEnvironments(singletonMap(ENVIRONMENT_NAME, environment)).build();
    stackSourceDto = newDto(StackSourceDto.class).withType(SOURCE_TYPE).withOrigin(SOURCE_ORIGIN);
    StackComponentDto stackComponentDto = newDto(StackComponentDto.class).withName(COMPONENT_NAME).withVersion(COMPONENT_VERSION);
    componentsDto = singletonList(stackComponentDto);
    stackDto = DtoFactory.getInstance().createDto(StackDto.class).withId(STACK_ID).withName(NAME).withDescription(DESCRIPTION).withScope(SCOPE).withCreator(CREATOR).withTags(tags).withSource(stackSourceDto).withComponents(componentsDto);
    stackImpl = StackImpl.builder().setId(STACK_ID).setName(NAME).setDescription(DESCRIPTION).setScope(SCOPE).setCreator(CREATOR).setTags(tags).setSource(stackSourceImpl).setComponents(componentsImpl).setWorkspaceConfig(workspaceConfig).setStackIcon(stackIcon).build();
    foreignStack = StackImpl.builder().setId(STACK_ID).setName(NAME).setDescription(DESCRIPTION).setScope(SCOPE).setCreator(FOREIGN_CREATOR).setTags(tags).setSource(stackSourceImpl).setComponents(componentsImpl).setWorkspaceConfig(workspaceConfig).setStackIcon(stackIcon).build();
    when(uriInfo.getBaseUriBuilder()).thenReturn(new UriBuilderImpl());
    final Field uriField = service.getClass().getSuperclass().getDeclaredField("uriInfo");
    uriField.setAccessible(true);
    uriField.set(service, uriInfo);
}
Also used : CommandImpl(org.eclipse.che.api.machine.server.model.impl.CommandImpl) Field(java.lang.reflect.Field) StackComponentImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl) StackComponentDto(org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto) StackDto(org.eclipse.che.api.workspace.shared.dto.stack.StackDto) StackIcon(org.eclipse.che.api.workspace.server.stack.image.StackIcon) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) StackSourceImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl) StackSourceDto(org.eclipse.che.api.workspace.shared.dto.stack.StackSourceDto) UriBuilderImpl(org.everrest.core.impl.uri.UriBuilderImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with WorkspaceConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl in project che by eclipse.

the class StackDaoTest method createStack.

private static StackImpl createStack(String id, String name) {
    final StackImpl stack = StackImpl.builder().setId(id).setName(name).setCreator("user123").setDescription(id + "-description").setScope(id + "-scope").setTags(asList(id + "-tag1", id + "-tag2")).setComponents(asList(new StackComponentImpl(id + "-component1", id + "-component1-version"), new StackComponentImpl(id + "-component2", id + "-component2-version"))).setSource(new StackSourceImpl(id + "-type", id + "-origin")).setStackIcon(new StackIcon(id + "-icon", id + "-media-type", "0x1234567890abcdef".getBytes())).build();
    final WorkspaceConfigImpl config = createWorkspaceConfig("test");
    stack.setWorkspaceConfig(config);
    return stack;
}
Also used : StackComponentImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl) StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) StackIcon(org.eclipse.che.api.workspace.server.stack.image.StackIcon) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) StackSourceImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl)

Example 9 with WorkspaceConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl in project che by eclipse.

the class JpaWorkspaceDaoTest method shouldCascadeRemoveObjectsWhenTheyRemovedFromEntity.

@Test
public void shouldCascadeRemoveObjectsWhenTheyRemovedFromEntity() {
    final AccountImpl account = new AccountImpl("accountId", "namespace", "test");
    final WorkspaceImpl workspace = createWorkspace("id", account, "name");
    // Persist the account
    manager.getTransaction().begin();
    manager.persist(account);
    manager.getTransaction().commit();
    manager.clear();
    // Persist the workspace
    manager.getTransaction().begin();
    manager.persist(workspace);
    manager.getTransaction().commit();
    manager.clear();
    // Cleanup one to many dependencies
    manager.getTransaction().begin();
    final WorkspaceConfigImpl config = workspace.getConfig();
    config.getProjects().clear();
    config.getCommands().clear();
    config.getEnvironments().clear();
    manager.merge(workspace);
    manager.getTransaction().commit();
    manager.clear();
    // If all the One To Many dependencies are removed then all the embedded objects
    // which depend on those object are also removed, which guaranteed by foreign key constraints
    assertEquals(asLong("SELECT COUNT(p) FROM ProjectConfig p"), 0L, "Project configs");
    assertEquals(asLong("SELECT COUNT(c) FROM Command c"), 0L, "Commands");
    assertEquals(asLong("SELECT COUNT(e) FROM Environment e"), 0L, "Environments");
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test)

Example 10 with WorkspaceConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl in project che by eclipse.

the class WorkspaceDaoTest method createWorkspace.

public 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);
    workspace.setAttributes(new HashMap<>(ImmutableMap.of("attr1", "value1", "attr2", "value2", "attr3", "value3")));
    workspace.setConfig(wCfg);
    return workspace;
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)

Aggregations

WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)10 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)6 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)5 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)4 ArrayList (java.util.ArrayList)3 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)3 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)3 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)3 ServerConf2Impl (org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl)3 SourceStorageImpl (org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl)3 Test (org.testng.annotations.Test)3 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 StackComponentImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl)2 StackSourceImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl)2 StackIcon (org.eclipse.che.api.workspace.server.stack.image.StackIcon)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Field (java.lang.reflect.Field)1 Path (java.nio.file.Path)1