Search in sources :

Example 1 with StackSourceDto

use of org.eclipse.che.api.workspace.shared.dto.stack.StackSourceDto in project che by eclipse.

the class DtoConverter method asDto.

/** Convert {@link StackImpl} to {@link StackDto}. */
public static StackDto asDto(Stack stack) {
    WorkspaceConfigDto workspaceConfigDto = null;
    if (stack.getWorkspaceConfig() != null) {
        workspaceConfigDto = asDto(stack.getWorkspaceConfig());
    }
    StackSourceDto stackSourceDto = null;
    StackSource source = stack.getSource();
    if (source != null) {
        stackSourceDto = newDto(StackSourceDto.class).withType(source.getType()).withOrigin(source.getOrigin());
    }
    List<StackComponentDto> componentsDto = null;
    if (stack.getComponents() != null) {
        componentsDto = stack.getComponents().stream().map(component -> newDto(StackComponentDto.class).withName(component.getName()).withVersion(component.getVersion())).collect(toList());
    }
    return newDto(StackDto.class).withId(stack.getId()).withName(stack.getName()).withDescription(stack.getDescription()).withCreator(stack.getCreator()).withScope(stack.getScope()).withTags(stack.getTags()).withComponents(componentsDto).withWorkspaceConfig(workspaceConfigDto).withSource(stackSourceDto);
}
Also used : StackComponentDto(org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto) StackDto(org.eclipse.che.api.workspace.shared.dto.stack.StackDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) StackSourceDto(org.eclipse.che.api.workspace.shared.dto.stack.StackSourceDto) StackSource(org.eclipse.che.api.workspace.shared.stack.StackSource)

Example 2 with StackSourceDto

use of org.eclipse.che.api.workspace.shared.dto.stack.StackSourceDto 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)

Aggregations

StackComponentDto (org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto)2 StackDto (org.eclipse.che.api.workspace.shared.dto.stack.StackDto)2 StackSourceDto (org.eclipse.che.api.workspace.shared.dto.stack.StackSourceDto)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 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)1 StackComponentImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl)1 StackSourceImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl)1 StackIcon (org.eclipse.che.api.workspace.server.stack.image.StackIcon)1 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)1 StackSource (org.eclipse.che.api.workspace.shared.stack.StackSource)1 UriBuilderImpl (org.everrest.core.impl.uri.UriBuilderImpl)1 BeforeMethod (org.testng.annotations.BeforeMethod)1