Search in sources :

Example 16 with CommandImpl

use of org.eclipse.che.api.machine.server.model.impl.CommandImpl 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 17 with CommandImpl

use of org.eclipse.che.api.machine.server.model.impl.CommandImpl in project che by eclipse.

the class WorkspaceServiceTest method shouldDeleteCommand.

@Test
public void shouldDeleteCommand() throws Exception {
    final WorkspaceImpl workspace = createWorkspace(createConfigDto());
    when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
    final int commandsSizeBefore = workspace.getConfig().getCommands().size();
    final CommandImpl firstCommand = workspace.getConfig().getCommands().iterator().next();
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().delete(SECURE_PATH + "/workspace/" + workspace.getId() + "/command/" + firstCommand.getName());
    assertEquals(response.getStatusCode(), 204);
    assertEquals(workspace.getConfig().getCommands().size(), commandsSizeBefore - 1);
    verify(wsManager).updateWorkspace(any(), any());
}
Also used : CommandImpl(org.eclipse.che.api.machine.server.model.impl.CommandImpl) Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Aggregations

CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)17 Command (org.eclipse.che.api.core.model.machine.Command)7 ConflictException (org.eclipse.che.api.core.ConflictException)6 ListLineConsumer (org.eclipse.che.api.core.util.ListLineConsumer)5 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)5 MachineException (org.eclipse.che.api.machine.server.exception.MachineException)4 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)4 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)4 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 NotFoundException (org.eclipse.che.api.core.NotFoundException)3 ServerException (org.eclipse.che.api.core.ServerException)3 InstanceProcess (org.eclipse.che.api.machine.server.spi.InstanceProcess)3 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)3 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)3 ServerConf2Impl (org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl)3 SourceStorageImpl (org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl)3 SshMachineProcess (org.eclipse.che.plugin.machine.ssh.SshMachineProcess)3 Test (org.testng.annotations.Test)3