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