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);
}
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);
}
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);
}
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);
}
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()));
}
Aggregations