Search in sources :

Example 6 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfDefaultEnvNameIsEmpty.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Workspace default environment name required")
public void shouldFailValidationIfDefaultEnvNameIsEmpty() throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.setDefaultEnv("");
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 7 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfNameIsInvalid.

@Test(dataProvider = "invalidNameProvider", expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Incorrect workspace name, it must be between 3 and 20 characters and may contain digits, " + "latin letters, underscores, dots, dashes and should start and end only with digits, " + "latin letters or underscores")
public void shouldFailValidationIfNameIsInvalid(String name) throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.withName(name);
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 8 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfCommandLineIsNull.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Command line required for command '.*'")
public void shouldFailValidationIfCommandLineIsNull() throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.getCommands().get(0).withCommandLine(null);
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 9 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfDefaultEnvNameIsNull.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Workspace default environment name required")
public void shouldFailValidationIfDefaultEnvNameIsNull() throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.setDefaultEnv(null);
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 10 with WorkspaceConfigDto

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

the class WorkspaceServiceTest method shouldRelativizeLinksOnCreateWorkspace.

@Test
public void shouldRelativizeLinksOnCreateWorkspace() throws Exception {
    final String initialLocation = "http://localhost:8080/api/recipe/idrecipe123456789/script";
    final WorkspaceConfigDto configDto = createConfigDto();
    configDto.getEnvironments().get(configDto.getDefaultEnv()).getRecipe().withLocation(initialLocation).withType("dockerfile");
    ArgumentCaptor<WorkspaceConfigDto> captor = ArgumentCaptor.forClass(WorkspaceConfigDto.class);
    when(wsManager.createWorkspace(captor.capture(), any(), any())).thenAnswer(invocation -> createWorkspace(captor.getValue()));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(configDto).when().post(SECURE_PATH + "/workspace" + "?namespace=test" + "&attribute=stackId:stack123" + "&attribute=custom:custom:value");
    assertEquals(response.getStatusCode(), 201);
    String savedLocation = unwrapDto(response, WorkspaceDto.class).getConfig().getEnvironments().get(configDto.getDefaultEnv()).getRecipe().getLocation();
    assertEquals(savedLocation, initialLocation.substring(API_ENDPOINT.length()));
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Aggregations

WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)29 Test (org.testng.annotations.Test)17 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)8 HashMap (java.util.HashMap)6 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)6 Test (org.junit.Test)5 ExtendedMachineDto (org.eclipse.che.api.workspace.shared.dto.ExtendedMachineDto)4 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Response (com.jayway.restassured.response.Response)3 CommandDto (org.eclipse.che.api.machine.shared.dto.CommandDto)3 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)3 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)3 EnvironmentRecipeDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentRecipeDto)3 WorkspaceRuntimeDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)2 StackComponentDto (org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto)2 StackDto (org.eclipse.che.api.workspace.shared.dto.stack.StackDto)2