Search in sources :

Example 21 with WorkspaceConfigDto

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);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 22 with WorkspaceConfigDto

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);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 23 with WorkspaceConfigDto

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);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 24 with WorkspaceConfigDto

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;
}
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 25 with 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");
        }
    }
}
Also used : HashMap(java.util.HashMap) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Model(org.eclipse.che.ide.maven.tools.Model) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) List(java.util.List) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Test(org.junit.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