use of org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto in project che by eclipse.
the class DefaultWorkspaceValidatorTest method shouldFailValidationIfCommandLineIsEmpty.
@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Command line required for command '.*'")
public void shouldFailValidationIfCommandLineIsEmpty() throws Exception {
final WorkspaceConfigDto config = createConfig();
config.getCommands().get(0).withCommandLine("");
wsValidator.validateConfig(config);
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto in project che by eclipse.
the class DefaultWorkspaceValidatorTest method shouldFailValidationIfCommandNameIsEmpty.
@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Workspace ws-name contains command with null or empty name")
public void shouldFailValidationIfCommandNameIsEmpty() throws Exception {
final WorkspaceConfigDto config = createConfig();
config.getCommands().get(0).withName(null);
wsValidator.validateConfig(config);
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto in project che by eclipse.
the class DefaultWorkspaceValidatorTest method shouldFailValidationIfEnvWithDefaultEnvNameIsNull.
@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Workspace default environment configuration required")
public void shouldFailValidationIfEnvWithDefaultEnvNameIsNull() throws Exception {
final WorkspaceConfigDto config = createConfig();
config.setEnvironments(null);
wsValidator.validateConfig(config);
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto 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;
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto in project che by eclipse.
the class MavenProjectTypeTest method testMavenProject.
@Test
public void testMavenProject() throws Exception {
WorkspaceDto usersWorkspaceMock = mock(WorkspaceDto.class);
WorkspaceConfigDto workspaceConfigMock = mock(WorkspaceConfigDto.class);
when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class).withMethod("GET").withHref("/workspace/")))).thenReturn(httpJsonRequest);
when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class).withMethod("PUT").withHref("/workspace/" + "/project")))).thenReturn(httpJsonRequest);
when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
when(httpJsonResponse.asDto(WorkspaceDto.class)).thenReturn(usersWorkspaceMock);
final ProjectConfigDto projectConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class).withName("project").withPath("/myProject").withType(MavenAttributes.MAVEN_ID);
when(usersWorkspaceMock.getConfig()).thenReturn(workspaceConfigMock);
when(workspaceConfigMock.getProjects()).thenReturn(Collections.singletonList(projectConfig));
Map<String, List<String>> attributes = new HashMap<>();
attributes.put(MavenAttributes.ARTIFACT_ID, Collections.singletonList("myartifact"));
attributes.put(MavenAttributes.GROUP_ID, Collections.singletonList("mygroup"));
attributes.put(MavenAttributes.VERSION, Collections.singletonList("1.0"));
attributes.put(MavenAttributes.PACKAGING, Collections.singletonList("jar"));
RegisteredProject project = pm.createProject(DtoFactory.getInstance().createDto(ProjectConfigDto.class).withType("maven").withAttributes(attributes).withPath("/myProject").withName("myProject"), new HashMap<>(0));
for (VirtualFileEntry file : project.getBaseFolder().getChildren()) {
if (file.getName().equals("pom.xml")) {
Model pom = Model.readFrom(file.getVirtualFile().getContent());
Assert.assertEquals(pom.getVersion(), "1.0");
}
}
}
Aggregations