Search in sources :

Example 1 with StackSourceImpl

use of org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl 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 2 with StackSourceImpl

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

the class StackDaoTest method shouldUpdateStack.

@Test(dependsOnMethods = "shouldGetById")
public void shouldUpdateStack() throws Exception {
    final StackImpl stack = stacks[0];
    stack.setName("new-name");
    stack.setCreator("new-creator");
    stack.setDescription("new-description");
    stack.setScope("new-scope");
    stack.getTags().clear();
    stack.getTags().add("new-tag");
    // Remove an existing component
    stack.getComponents().remove(1);
    // Add a new component
    stack.getComponents().add(new StackComponentImpl("component3", "component3-version"));
    // Update an existing component
    final StackComponentImpl component = stack.getComponents().get(0);
    component.setName("new-name");
    component.setVersion("new-version");
    // Updating source
    final StackSourceImpl source = stack.getSource();
    source.setType("new-type");
    source.setOrigin("new-source");
    // Set a new icon
    stack.setStackIcon(new StackIcon("new-name", "new-media", "new-data".getBytes()));
    stackDao.update(stack);
    assertEquals(stackDao.getById(stack.getId()), new StackImpl(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) StackSourceImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl) Test(org.testng.annotations.Test)

Example 3 with StackSourceImpl

use of org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl 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)

Aggregations

StackComponentImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl)3 StackSourceImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl)3 StackIcon (org.eclipse.che.api.workspace.server.stack.image.StackIcon)3 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)2 StackImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl)2 Field (java.lang.reflect.Field)1 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)1 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)1 StackComponentDto (org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto)1 StackDto (org.eclipse.che.api.workspace.shared.dto.stack.StackDto)1 StackSourceDto (org.eclipse.che.api.workspace.shared.dto.stack.StackSourceDto)1 UriBuilderImpl (org.everrest.core.impl.uri.UriBuilderImpl)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1