ProjectConverter { public ProjectImpl toDevfileProject(ProjectConfigImpl projectConfig) { String branch = projectConfig.getSource().getParameters().get(BRANCH_PARAMETER_NAME); String startPoint = projectConfig.getSource().getParameters().get(START_POINT_PARAMETER_NAME); String tag = projectConfig.getSource().getParameters().get(TAG_PARAMETER_NAME); String commitId = projectConfig.getSource().getParameters().get(COMMIT_ID_PARAMETER_NAME); String sparseCheckoutDir = projectConfig.getSource().getParameters().get(SPARSE_CHECKOUT_DIR_PARAMETER_NAME); SourceImpl source = new SourceImpl( projectConfig.getSource().getType(), projectConfig.getSource().getLocation(), branch, startPoint, tag, commitId, sparseCheckoutDir); String path = projectConfig.getPath(); while (path != null && path.startsWith("/")) { path = path.substring(1); } if (projectConfig.getName().equals(path)) { path = null; } return new ProjectImpl(projectConfig.getName(), source, path); }  ProjectImpl toDevfileProject(ProjectConfigImpl projectConfig); ProjectConfigImpl toWorkspaceProject(Project devProject);  }
@Test public void testConvertingProjectConfigToDevfileProject() { ProjectConfigImpl workspaceProject = new ProjectConfigImpl(); workspaceProject.setName("myProject"); workspaceProject.setPath("/clone/path"); SourceStorageImpl sourceStorage = new SourceStorageImpl(); sourceStorage.setType("git"); sourceStorage.setLocation("https: sourceStorage.setParameters( ImmutableMap.of(TAG_PARAMETER_NAME, "v1.0", BRANCH_PARAMETER_NAME, "develop")); workspaceProject.setSource(sourceStorage); Project devfileProject = projectConverter.toDevfileProject(workspaceProject); assertEquals(devfileProject.getName(), "myProject"); Source source = devfileProject.getSource(); assertEquals(source.getType(), "git"); assertEquals(source.getLocation(), "https: assertEquals(source.getBranch(), "develop"); assertEquals(source.getTag(), "v1.0"); assertEquals(devfileProject.getClonePath(), "clone/path"); }