Search in sources :

Example 6 with CommandDto

use of org.eclipse.che.api.machine.shared.dto.CommandDto in project che by eclipse.

the class DefaultWorkspaceValidatorTest method createConfig.

private static WorkspaceConfigDto createConfig() {
    final WorkspaceConfigDto workspaceConfigDto = newDto(WorkspaceConfigDto.class).withName("ws-name").withDefaultEnv("dev-env");
    ExtendedMachineDto extendedMachine = newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent")).withServers(singletonMap("ref1", newDto(ServerConf2Dto.class).withPort("8080/tcp").withProtocol("https").withProperties(singletonMap("some", "prop")))).withAttributes(singletonMap("memoryLimitBytes", "1000000"));
    EnvironmentDto env = newDto(EnvironmentDto.class).withMachines(singletonMap("devmachine1", extendedMachine)).withRecipe(newDto(EnvironmentRecipeDto.class).withType("type").withContent("content").withContentType("content type"));
    workspaceConfigDto.setEnvironments(singletonMap("dev-env", env));
    List<CommandDto> commandDtos = new ArrayList<>();
    commandDtos.add(newDto(CommandDto.class).withName("command_name").withType("maven").withCommandLine("mvn clean install").withAttributes(new HashMap<>(singletonMap("cmd-attribute-name", "cmd-attribute-value"))));
    workspaceConfigDto.setCommands(commandDtos);
    return workspaceConfigDto;
}
Also used : HashMap(java.util.HashMap) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) ArrayList(java.util.ArrayList) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) CommandDto(org.eclipse.che.api.machine.shared.dto.CommandDto) ExtendedMachineDto(org.eclipse.che.api.workspace.shared.dto.ExtendedMachineDto)

Example 7 with CommandDto

use of org.eclipse.che.api.machine.shared.dto.CommandDto in project che by eclipse.

the class WorkspaceServiceTest method shouldAddCommand.

@Test
public void shouldAddCommand() throws Exception {
    final WorkspaceImpl workspace = createWorkspace(createConfigDto());
    when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
    when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
    final CommandDto commandDto = createCommandDto();
    final int commandsSizeBefore = workspace.getConfig().getCommands().size();
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(commandDto).when().post(SECURE_PATH + "/workspace/" + workspace.getId() + "/command");
    assertEquals(response.getStatusCode(), 200);
    assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT).getConfig().getCommands().size(), commandsSizeBefore + 1);
    verify(validator).validateConfig(workspace.getConfig());
    verify(wsManager).updateWorkspace(any(), any());
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) CommandDto(org.eclipse.che.api.machine.shared.dto.CommandDto) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Test(org.testng.annotations.Test)

Aggregations

CommandDto (org.eclipse.che.api.machine.shared.dto.CommandDto)7 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)3 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)3 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)3 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)3 Test (org.testng.annotations.Test)3 Response (com.jayway.restassured.response.Response)2 HashMap (java.util.HashMap)2 List (java.util.List)2 EnvironmentRecipeDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentRecipeDto)2 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)2 MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Maps (com.google.common.collect.Maps)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1