Search in sources :

Example 16 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DevfileConverterTest method shouldConvertProjectsDuringConvertingDevfileToWorkspaceConfig.

@Test
public void shouldConvertProjectsDuringConvertingDevfileToWorkspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    DevfileImpl devfile = newDevfile("petclinic");
    ProjectImpl devfileProject = mock(ProjectImpl.class);
    devfile.getProjects().add(devfileProject);
    ProjectConfigImpl workspaceProject = mock(ProjectConfigImpl.class);
    when(projectConverter.toWorkspaceProject(any())).thenReturn(workspaceProject);
    // when
    WorkspaceConfigImpl workspaceConfig = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
    // then
    assertEquals(workspaceConfig.getProjects().size(), 1);
    assertSame(workspaceConfig.getProjects().get(0), workspaceProject);
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) Test(org.testng.annotations.Test)

Example 17 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DevfileEntityProviderTest method shouldBuildDtoFromValidJson.

@Test
public void shouldBuildDtoFromValidJson() throws Exception {
    when(devfileParser.parseJson(anyString())).thenReturn(new DevfileImpl());
    devfileEntityProvider.readFrom(DevfileDto.class, DevfileDto.class, null, MediaType.APPLICATION_JSON_TYPE, new MultivaluedHashMap<>(), getClass().getClassLoader().getResourceAsStream("devfile/devfile.json"));
    verify(devfileParser).parseJson(anyString());
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 18 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DevfileEntityProviderTest method shouldBuildDtoFromValidYaml.

@Test
public void shouldBuildDtoFromValidYaml() throws Exception {
    when(devfileParser.parseYaml(anyString())).thenReturn(new DevfileImpl());
    devfileEntityProvider.readFrom(DevfileDto.class, DevfileDto.class, null, MediaType.valueOf("text/x-yaml"), new MultivaluedHashMap<>(), getClass().getClassLoader().getResourceAsStream("devfile/devfile.yaml"));
    verify(devfileParser).parseYaml(anyString());
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 19 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class WorkspaceEntityProviderTest method shouldBuildDtoFromValidJson.

@Test
public void shouldBuildDtoFromValidJson() throws Exception {
    when(devfileParser.parseJson(anyString())).thenReturn(new DevfileImpl());
    WorkspaceDto actual = newDto(WorkspaceDto.class).withDevfile(newDto(DevfileDto.class));
    workspaceEntityProvider.readFrom(WorkspaceDto.class, WorkspaceDto.class, null, MediaType.APPLICATION_JSON_TYPE, new MultivaluedHashMap<>(), new ByteArrayInputStream(DtoFactory.getInstance().toJson(actual).getBytes(StandardCharsets.UTF_8)));
    verify(devfileParser).parseJson(anyString());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) DevfileDto(org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto) Test(org.testng.annotations.Test)

Example 20 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class WorkspaceManagerTest method createsWorkspaceFromDevfileWithGenerateName.

@Test
public void createsWorkspaceFromDevfileWithGenerateName() throws ValidationException, ConflictException, NotFoundException, ServerException, InfrastructureException {
    final String testDevfileGenerateName = "ws-";
    final DevfileImpl devfile = new DevfileImpl();
    devfile.setApiVersion(CURRENT_API_VERSION);
    devfile.getMetadata().setGenerateName(testDevfileGenerateName);
    when(runtimes.evalInfrastructureNamespace(any())).thenReturn("ns");
    Workspace workspace = workspaceManager.createWorkspace(devfile, NAMESPACE_1, null, null);
    assertTrue(workspace.getDevfile().getName().startsWith(testDevfileGenerateName));
    assertEquals(workspace.getDevfile().getName().length(), testDevfileGenerateName.length() + WORKSPACE_GENERATE_NAME_CHARS_APPEND);
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Workspace(org.eclipse.che.api.core.model.workspace.Workspace) Test(org.testng.annotations.Test)

Aggregations

DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)162 Test (org.testng.annotations.Test)126 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)76 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)22 FileContentProvider (org.eclipse.che.api.workspace.server.devfile.FileContentProvider)20 MetadataImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl)20 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)18 ActionImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl)16 ProjectImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl)16 Container (io.fabric8.kubernetes.api.model.Container)14 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl)14 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)14 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)14 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)12 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)10 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 Secret (io.fabric8.kubernetes.api.model.Secret)10 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)10 HashMap (java.util.HashMap)10 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)10