Skip to content

Commit

Permalink
#16: corrected again project download
Browse files Browse the repository at this point in the history
  • Loading branch information
witchpou committed Dec 15, 2019
1 parent 16900a8 commit 9a7b3e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public String createTempProjectDirectory(final ProjectEntity project) throws Not
try {
Path destDir = null;
destDir = Files.createTempDirectory(Constants.LJ_PREFIX + project.getTitle());
return destDir.toString();
return destDir.getFileName().toString();
} catch (final IOException e) {
LOG.error("Error creating temporary folder for project", e);
final ResponseMetadata data = new ResponseMetadata(ResponseCode.ERROR,
Expand Down Expand Up @@ -76,7 +76,7 @@ public FileVisitResult postVisitDirectory(final Path dir, final IOException exc)
*/
public void checkoutProjectTemplate(final GeneratorDto dto) throws NotificationException {
final ProjectEntity entity = dto.getProject();
final String destDirString = entity.getTargetPath();
String destDirString = Constants.TMP_DIR + Constants.FILE_SEP + entity.getTargetPath();
final File destDir = new File(destDirString);
String srcDir = entity.getTemplate().getLocation();
String branch = Constants.DEFAULT_BRANCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void renameProjectTitle(ProjectEntity entity) throws NotificationExceptio
LOG.info("Try to rename project " + entity.getTemplate().getPackagePrefix() + ".");

File parentdirectory;
parentdirectory = new File(entity.getTargetPath());
parentdirectory = new File(Constants.TMP_DIR + Constants.FILE_SEP + entity.getTargetPath());
String currentProjectName = entity.getTemplate().getTitle();
renameDirectories(currentProjectName, entity.getTitle(), parentdirectory, false);
renameFiles(currentProjectName, entity.getTitle(), parentdirectory);
Expand All @@ -50,7 +50,7 @@ public void renamePackage(ProjectEntity entity) throws NotificationException {
LOG.info("Try to rename package " + entity.getTitle() + ".");

File parentdirectory;
parentdirectory = new File(entity.getTargetPath());
parentdirectory = new File(Constants.TMP_DIR + Constants.FILE_SEP + entity.getTargetPath());
renameDirectories(entity.getTemplate().getPackagePrefix(), entity.getPackagePrefix(), parentdirectory, true);
renameFiles(entity.getTemplate().getPackagePrefix(), entity.getPackagePrefix(), parentdirectory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.log4j.Logger;
import org.junit.Test;

import de.starwit.generator.config.Constants;
import de.starwit.generator.services.Git;
import de.starwit.generator.services.ProjectCheckout;
import de.starwit.generator.services.StartupShutdownService;
Expand All @@ -22,20 +23,20 @@ public class ProjectCheckoutTest {

@Test
public void cloneGitRepoWithoutAuthTest() throws NotificationException, IOException, InterruptedException {
final Path destDir = this.createDirectory("tmplirejarp").toPath();
String dir = destDir.toAbsolutePath().toString();
final Path destDir = this.createDirectory(Constants.TMP_DIR + Constants.FILE_SEP + "tmplirejarp").toPath();
String dir = destDir.toString();
LOG.info("Path is " + dir);
Git.gitClone(destDir, "https://github.com/witchpou/lirejarp.git", "master");

String[] dirContent = destDir.toFile().list();
assertTrue("Cloning repository results in an empty directory.", (dirContent != null && dirContent.length > 0));
checkout.deleteTempProject("tmplirejarp");
checkout.deleteTempProject(dir);
}

private File createDirectory(final String location) {
final File file = new File(location);
if (file.exists()) {
checkout.deleteTempProject("tmplirejarp");
checkout.deleteTempProject(location);
fail("Directory " + location + "should not exist.");
}
final boolean iscreated = file.mkdir();
Expand Down

0 comments on commit 9a7b3e5

Please sign in to comment.