diff --git a/pom.xml b/pom.xml index 4c4643826b12e4d0b17a4382d95ec5c1c7679762..6acecbd5badf0374118cc334eb04acd8747cd93a 100644 --- a/pom.xml +++ b/pom.xml @@ -155,7 +155,7 @@ <dependency> <groupId>org.codeability.sharing</groupId> <artifactId>SharingPluginPlatformAPI</artifactId> - <version>0.3.1</version> + <version>0.3.2</version> </dependency> <dependency> <groupId>org.springdoc</groupId> diff --git a/src/main/java/at/ac/uibk/gitsearch/service/ExerciseService.java b/src/main/java/at/ac/uibk/gitsearch/service/ExerciseService.java index 2298ed0095098524f1a3563adc55c332535edf92..b1876f943a69db7cb2c6b4ebba8e14011bf5cf90 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/ExerciseService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/ExerciseService.java @@ -19,6 +19,7 @@ import java.net.URISyntaxException; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Objects; import java.util.zip.ZipEntry; @@ -61,7 +62,7 @@ public class ExerciseService { /** * Retrieve a zipped Artemis Exercise from a given URL - * and store it in 'tmp-import' directory + * and store it in a temporary directory * @param exerciseUrl the url of the exposed exercise * @throws ArtemisImportError */ @@ -97,7 +98,7 @@ public class ExerciseService { * - Copy, commit and push files to the new repository * * @param exerciseInfo of the exercise to import - * @param exerciseToken of the stored exercise (in '/tmp-import' directory) to import + * @param exerciseToken of the stored exercise (in the temporary directory) to import */ public void importExercise(ArtemisExerciseInfo exerciseInfo, String exerciseToken, Integer gitlabGroupId) throws GitLabApiException, GitAPIException, IOException, ArtemisImportError { @@ -108,11 +109,11 @@ public class ExerciseService { Group group = gitlabService.getGroupById(gitlabGroupId); String repoUrl = gitlabService.createRepository(group, exerciseInfo.getTitle()); Repository repo = gitlabService.checkoutRepo(repoUrl); - gitlabService.commitAndPushToRepo(repo, new File("tmp-import", exerciseToken)); + gitlabService.commitAndPushToRepo(repo, new File(System.getProperty("java.io.tmpdir"), exerciseToken)); repo.close(); try { - FileUtils.deleteDirectory(new File("tmp-import", exerciseToken)); + FileUtils.deleteDirectory(new File(System.getProperty("java.io.tmpdir"), exerciseToken)); FileUtils.deleteDirectory(repo.getDirectory().getParentFile()); } catch (IOException e) { log.error("Could not remove directory: {} \n", e.getMessage()); @@ -132,7 +133,8 @@ public class ExerciseService { .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); File exerciseDetailsFile = Objects.requireNonNull( - new File("tmp-import", exerciseToken).listFiles((file, name) -> name.startsWith("Exercise-Details-") && name.endsWith(".json")) + new File(System.getProperty("java.io.tmpdir"), exerciseToken) + .listFiles((file, name) -> name.startsWith("Exercise-Details-") && name.endsWith(".json")) )[0]; mapArtemisExerciseInfoValues(exerciseDetailsFile); @@ -215,7 +217,7 @@ public class ExerciseService { } /** - * Used to temporary store content of Zip-File into a tmp-subdirectory + * Used to temporary store content of Artemis' exercises Zip-Files into a tmp-subdirectory * * Recursion is used in case of nested Zip-Files * @@ -223,75 +225,97 @@ public class ExerciseService { * @param subDir name of the tmp-subdirectory */ private void storeZipInTmp(ZipInputStream zipInputStream, String subDir) throws IOException { - if (!new File("tmp-import").exists() && !new File("tmp-import").mkdir()) { - throw new IOException("Could not create missing '/tmp-import' directory"); - } - File tmpDir = new File("tmp-import", subDir); - if (!tmpDir.exists() && !tmpDir.mkdir()) { - throw new IOException("Temporary exercise directory could not be created"); + Path targetDir; + + if (subDir.startsWith(System.getProperty("java.io.tmpdir"))) { + targetDir = Files.createDirectories(Paths.get(subDir)); + } else { + targetDir = Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir"), subDir)); } ZipEntry zipEntry; - // https://www.baeldung.com/java-compress-and-uncompress while ((zipEntry = zipInputStream.getNextEntry()) != null) { if (zipEntry.getName().contains(".git")) { // important as Artemis exercises come in submodules continue; } - File entryFile = new File(tmpDir, zipEntry.getName()); - if (zipEntry.getName().endsWith(".zip")) { - writeFile(entryFile, zipInputStream); + + Path zipEntryPath = Paths.get(targetDir.toString(), zipEntry.getName()); + + if (isZipFile(zipEntry)) { + writeFile(zipEntryPath.toFile(), zipInputStream); String newSubDir; if (StringUtils.endsWithAny(zipEntry.getName(), new String[] { "-exercise.zip", "-solution.zip", "-tests.zip" })) { - // extract repo directory name only - newSubDir = - Paths - .get( - entryFile.getParentFile().getParent(), - zipEntry.getName().substring(zipEntry.getName().lastIndexOf("-") + 1, zipEntry.getName().lastIndexOf(".")) - ) - .toString(); + newSubDir = Paths.get(targetDir.getParent().toString(), getRepoNameFromZipEntry(zipEntry)).toString(); } else { - newSubDir = Paths.get(subDir, entryFile.getName()).toString(); - newSubDir = newSubDir.substring(0, newSubDir.lastIndexOf(".")); // remove '.zip' from path - } - if (newSubDir.startsWith("tmp-import")) { - newSubDir = newSubDir.replaceFirst("tmp-import/", ""); + newSubDir = + Paths.get(targetDir.toString(), zipEntry.getName().substring(0, zipEntry.getName().lastIndexOf("."))).toString(); } - storeZipInTmp(new ZipInputStream(new FileInputStream(entryFile)), newSubDir); - if (Files.deleteIfExists(entryFile.toPath())) { - log.warn("Unable to delete temporary Zip file [{}] after extraction. Skipping..", entryFile.getPath()); + + storeZipInTmp(new ZipInputStream(new FileInputStream(zipEntryPath.toFile())), newSubDir); + if (Files.deleteIfExists(zipEntryPath)) { + log.warn("Unable to delete temporary Zip file [{}] after extraction. Skipping..", zipEntryPath); } } else if (zipEntry.isDirectory()) { - if (!entryFile.mkdir()) { - throw new IOException("Failed to create directory " + entryFile); - } - } else if (!zipEntry.getName().endsWith(".zip")) { - // fix for Windows-created archives - File parent = entryFile.getParentFile(); - if (!parent.isDirectory() && !parent.mkdirs()) { - throw new IOException("Failed to create directory " + parent); - } - - writeFile(entryFile, zipInputStream); + Files.createDirectory(zipEntryPath); + } else { + writeFile(zipEntryPath.toFile(), zipInputStream); } } - if (tmpDir.isDirectory() && fileService.isEmpty(tmpDir.toPath())) { - Files.delete(tmpDir.toPath()); - } + cleanUpTmpDirectory(targetDir.toFile()); zipInputStream.close(); - fileService.scheduleForDeletion(tmpDir.toPath(), 60); } /** - * Method used to write files from zip inputStreams + * Utility method used to check if a ZipEntry represents a Zip file + * @param zipEntry to check + * @return true if zipEntry is a Zip file, false otherwise + */ + private boolean isZipFile(ZipEntry zipEntry) { + return zipEntry.getName().endsWith(".zip"); + } + + /** + * Cleans up a temporary directory by removing it if empty + * or scheduling its deletion with a delay of 60 minutes, otherwise. + * + * @param tmpDir to clean up + */ + private void cleanUpTmpDirectory(File tmpDir) { + try { + if (tmpDir.exists() && tmpDir.isDirectory() && fileService.isEmpty(tmpDir.toPath())) { + Files.delete(tmpDir.toPath()); + } + fileService.scheduleForDeletion(tmpDir.toPath(), 60); + } catch (IOException e) { + log.error("An error occurred while cleaning up a temporary directory: ", e); + } + } + + /** + * Utility method used to extract the repository name from Zip files + * representing git submodules. (Artemis exercise exports come in + * submodules for 'exercise', 'solution' and 'test') + * @param zipEntry to get the repository name from + * @return the repository name + */ + private String getRepoNameFromZipEntry(ZipEntry zipEntry) { + return zipEntry.getName().substring(zipEntry.getName().lastIndexOf("-") + 1, zipEntry.getName().lastIndexOf(".")); + } + + /** + * Method used to write files from a zipInputStream * @param entryFile File to write - * @param zipInputStream Byte stream to write + * @param zipInputStream Byte stream to read from * @throws IOException */ private void writeFile(File entryFile, ZipInputStream zipInputStream) throws IOException { byte[] buffer = new byte[1024]; + if (!entryFile.getParentFile().exists()) { + Files.createDirectories(entryFile.getParentFile().toPath()); + } + try (FileOutputStream fos = new FileOutputStream(entryFile)) { int len; while ((len = zipInputStream.read(buffer)) > 0) { @@ -310,7 +334,10 @@ public class ExerciseService { ObjectMapper mapper = new ObjectMapper( new YAMLFactory().enable(YAMLGenerator.Feature.INDENT_ARRAYS).disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) ); - mapper.writeValue(new File("tmp-import/" + exerciseToken, "metadata.yaml"), exerciseInfo.getExerciseInfoOnly()); + mapper.writeValue( + Paths.get(System.getProperty("java.io.tmpdir"), exerciseToken, "metadata.yaml").toFile(), + exerciseInfo.getExerciseInfoOnly() + ); } /** @@ -357,19 +384,19 @@ public class ExerciseService { private void renameFiles(String exerciseToken) { try { File problemStatementFile = Objects.requireNonNull( - new File("tmp-import", exerciseToken) + new File(System.getProperty("java.io.tmpdir"), exerciseToken) .listFiles((file, name) -> name.startsWith("Problem-Statement-") && name.endsWith(".md")) )[0]; - if (!problemStatementFile.renameTo(new File("tmp-import" + File.separator + exerciseToken, "exercise.md"))) { + if (!problemStatementFile.renameTo(Paths.get(System.getProperty("java.io.tmpdir"), exerciseToken, "exercise.md").toFile())) { log.error("Unable to rename file [{}]. Skipping..", problemStatementFile.getName()); } File exerciseDetailsFile = Objects.requireNonNull( - new File("tmp-import", exerciseToken) + new File(System.getProperty("java.io.tmpdir"), exerciseToken) .listFiles((file, name) -> name.startsWith("Exercise-Details-") && name.endsWith(".json")) )[0]; Files.move(exerciseDetailsFile.toPath(), exerciseDetailsFile.toPath().resolveSibling("Exercise-Details.json")); } catch (ArrayIndexOutOfBoundsException e) { - log.error("File to rename could not be found in [{}].", "tmp-import" + File.separator + exerciseToken); + log.error("File to rename could not be found in [{}].", System.getProperty("java.io.tmpdir") + File.separator + exerciseToken); } catch (IOException ioe) { log.error("Error while renaming file: {}", ioe.getMessage()); } diff --git a/src/main/java/at/ac/uibk/gitsearch/service/GitlabService.java b/src/main/java/at/ac/uibk/gitsearch/service/GitlabService.java index da99c211f6e33ad7afec049f45532a44239a5f16..d1e5c8e7ab81187b3246f4322316ae1db53b920b 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/GitlabService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/GitlabService.java @@ -277,14 +277,14 @@ public class GitlabService { */ public Repository checkoutRepo(String repoUrl) throws ArtemisImportError { String repoDirName = repoUrl.split("/")[repoUrl.split("/").length - 1]; - File dst = new File("tmp-import", repoDirName); + File dst = new File(System.getProperty("java.io.tmpdir"), repoDirName); if (dst.exists()) { log.debug("Temporary directory '{}' already exists, removing it.", dst.getPath()); try { FileUtils.deleteDirectory(dst); } catch (IOException e) { log.error("Unable to remove directory. Create another directory : {} \n", e.getMessage()); - dst = new File("tmp-import", repoDirName + UUID.randomUUID()); + dst = new File(System.getProperty("java.io.tmpdir"), repoDirName + UUID.randomUUID()); } } try { diff --git a/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java b/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java index 243bc2a30d3fff91cd3b90098d92b371530db74e..30023267df6937c4f6cb56184b14eb32bf5ff832 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java @@ -329,15 +329,15 @@ public class SearchService { throw e; } } - ZipInputStream project = shoppingBasketService.rePackageGitLabProjectZip( + InputStream project = shoppingBasketService.rePackageGitLabProjectZip( new ZipInputStream(repositoryArchive), "from project " + exerciseId.getProjectId(), filter, exerciseId.getPath() ); - if (recursive == ExtractionDepth.JUST_PROJECT) return project; else { + if (recursive == ExtractionDepth.JUST_PROJECT) return new ZipInputStream(project); else { alreadyTreatedExerciseIds.add(exerciseId); // Side effects are always dangerous :-( - return extendZipByChildren(exerciseId, project, user, recursive, alreadyTreatedExerciseIds); + return extendZipByChildren(exerciseId, new ZipInputStream(project), user, recursive, alreadyTreatedExerciseIds); } } catch (GitLabApiException exception) { log.error(exception.getMessage()); diff --git a/src/main/java/at/ac/uibk/gitsearch/service/ShoppingBasketService.java b/src/main/java/at/ac/uibk/gitsearch/service/ShoppingBasketService.java index 3eadb3fe1aee07e1ebf690ef950deff6225056d3..bd7821b7dce5afc3d9eb82dd669f8b7df98662e2 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/ShoppingBasketService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/ShoppingBasketService.java @@ -319,7 +319,7 @@ public class ShoppingBasketService { * @return * @throws IOException */ - protected ZipInputStream rePackageGitLabProjectZip( + protected InputStream rePackageGitLabProjectZip( ZipInputStream zipIn, String originalLocation, String[] filterOut, @@ -359,15 +359,14 @@ public class ShoppingBasketService { zipInEntry = zipIn.getNextEntry(); } zipIn.close(); - zipOut.close(); } catch (IOException e) { - log.error("Cannot rezip file from {}", originalLocation); + log.error("Cannot rezip file from {}", originalLocation, e); } }; new Thread(rePackage).start(); - return new ZipInputStream(pis); + return pis; } public String getExerciseFolderPath(String exercisesPath) { diff --git a/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.html b/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.html index 2433e9e540d600bda7bfc8c82f1e04b296d4300b..b7e684c6cc2a00b6d2ee4e21f387586be42cf215 100644 --- a/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.html +++ b/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.html @@ -1,4 +1,4 @@ -<div *ngIf="page"> +<div class="md-Container" *ngIf="page"> <markdown #pageMarkDown katex diff --git a/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.scss b/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.scss index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..50c714f1ea252c72d616a52165d579bfb0e484bd 100644 --- a/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.scss +++ b/src/main/webapp/app/editorialPages/markDownViewer/markDownViewer.component.scss @@ -0,0 +1,3 @@ +.md-Container { + padding: 20px; +} diff --git a/src/main/webapp/app/exercise/exercise-card/exercise-card.component.html b/src/main/webapp/app/exercise/exercise-card/exercise-card.component.html index 7be3107986e08ba1c84e12acb641efc651ee7e2e..77b370f0f2b336bcaed9d58e9c75ce497eed4b54 100644 --- a/src/main/webapp/app/exercise/exercise-card/exercise-card.component.html +++ b/src/main/webapp/app/exercise/exercise-card/exercise-card.component.html @@ -23,9 +23,10 @@ <div style="margin-top: auto; width: 100%; padding-left: 30px; padding-right: 30px"> <!-- card rating--> <div style="margin-bottom: 20px"> + <!-- <div style="float: left"> <p class="card-text" jhiTranslate="exercise.details.rating"></p> - </div> + </div> --> <div class="star-container"> <span class="star" diff --git a/src/main/webapp/app/exercise/service/exercise.service.ts b/src/main/webapp/app/exercise/service/exercise.service.ts index 5d0e70ff3555d583f5dc5eddd1119f2e1cb93c9f..12fe603cd6abd36e00de806c47e80e3ab4139d65 100644 --- a/src/main/webapp/app/exercise/service/exercise.service.ts +++ b/src/main/webapp/app/exercise/service/exercise.service.ts @@ -82,9 +82,7 @@ export class ExerciseService { * @param exerciseUrl */ public importExerciseInfoFromArtemis(exerciseToken: string): Observable<ArtemisExerciseInfo> { - return this.http.get<ArtemisExerciseInfo>( - `${encodeURIComponent(this.exerciseUrl)}imported-exercise-info/${encodeURIComponent(exerciseToken)}` - ); + return this.http.get<ArtemisExerciseInfo>(`${this.exerciseUrl}imported-exercise-info/${exerciseToken}`); } /** diff --git a/src/main/webapp/app/layouts/footer/footer.component.html b/src/main/webapp/app/layouts/footer/footer.component.html index a939de1b1223a80a8464d9737c4a1d420b2453f6..34b588bfc4645cae37479409976c6f65bc596f6b 100644 --- a/src/main/webapp/app/layouts/footer/footer.component.html +++ b/src/main/webapp/app/layouts/footer/footer.component.html @@ -1,20 +1,29 @@ <footer> <div class="footer fixed-bottom"> - <div class="row"> - <div class="col-lg-3 col-md-12 col-sm-12"> - <a href="https://codeability.uibk.ac.at/" jhiTranslate="global.footer.about">About codeAbility</a> + <div class="container"> + <div class="row"> + <div class="col-4"> + <a href="https://codeability.uibk.ac.at/" jhiTranslate="global.footer.about">About codeAbility</a> + </div> + <div class="col-4"> + <a href="https://www.uibk.ac.at/informatik/" jhiTranslate="global.footer.imprint">Imprint</a> + </div> + <div class="col-4"> + <a jhiTranslate="global.footer.privacy" routerLink="/datapolicy" routerLinkActive="active">Privacy</a> + </div> </div> - <div class="col-lg-3 col-md-12 col-sm-12"> - <a href="https://www.uibk.ac.at/informatik/" jhiTranslate="global.footer.imprint">Imprint</a> + <div class="row"> + <div class="col-9"></div> + <div + class="col-3" + style="float: right; font-size: 50%; padding-top: 15px" + *ngIf="applicationInfoService.getDeploymentInfo().branch" + > + {{ applicationInfoService.getDeploymentInfo().branch }}/{{ applicationInfoService.getDeploymentInfo().commitId }} ({{ + applicationInfoService.getDeploymentInfo().deploymentDate + }}) + </div> </div> - <div class="col-lg-3 col-md-12 col-sm-12"> - <a jhiTranslate="global.footer.privacy" routerLink="/datapolicy" routerLinkActive="active">Privacy</a> - </div> - </div> - <div style="float: right; font-size: 50%; padding-top: 15px" *ngIf="applicationInfoService.getDeploymentInfo().branch"> - {{ applicationInfoService.getDeploymentInfo().branch }}/{{ applicationInfoService.getDeploymentInfo().commitId }} ({{ - applicationInfoService.getDeploymentInfo().deploymentDate - }}) </div> </div> </footer> diff --git a/src/main/webapp/app/shared/gitlab/gitlab-path-selector/gitlab-path-selector.component.html b/src/main/webapp/app/shared/gitlab/gitlab-path-selector/gitlab-path-selector.component.html index bd3d5dc703ea0ebb67b1ef1dc043b1cf9a752e2a..7cc4db1adce563c2257921700ecc41fb939a8eda 100644 --- a/src/main/webapp/app/shared/gitlab/gitlab-path-selector/gitlab-path-selector.component.html +++ b/src/main/webapp/app/shared/gitlab/gitlab-path-selector/gitlab-path-selector.component.html @@ -9,9 +9,6 @@ <jhi-alert-error></jhi-alert-error> <div class="table-responsive p-1" *ngIf="!isLoading"> <table class="table table-striped"> - <caption> - GitLab Path Selection - </caption> <thead> <tr> <th scope="col"></th> @@ -47,6 +44,11 @@ </tbody> </table> </div> + <div *ngIf="groups && groups.length < 1"> + <div class="d-flex flex-wrap justify-content-center align-items-center my-4"> + <span class="h3">No Gitlab groups available for the import</span> + </div> + </div> <div *ngIf="isLoading"> <div class="h-100 w-100 d-flex justify-content-center align-items-center m-5"> <div class="spinner"></div> diff --git a/src/test/java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java b/src/test/java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java index 395af0a2c414d2f9be0c7104e9a49aa055e67c39..9dea881dd9af3cf1bcff7ee8ec152a58a74b6114 100644 --- a/src/test/java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java +++ b/src/test/java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java @@ -12,6 +12,7 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import org.apache.commons.io.FileUtils; @@ -58,8 +59,8 @@ public class ExerciseServiceIT { @After public void cleanUp() throws IOException { - if (new File("tmp-import/", token).exists()) { - FileUtils.deleteDirectory(new File("tmp-import/" + token)); + if (new File(System.getProperty("java.io.tmpdir"), token).exists()) { + FileUtils.deleteDirectory(new File(System.getProperty("java.io.tmpdir") + token)); } } @@ -67,29 +68,29 @@ public class ExerciseServiceIT { public void testImportExercise() throws Exception { int gitlabGroup = 1; - File metadata = new File("tmp-import/" + token, "Exercise-Details-something.json"); + File metadata = Paths.get(System.getProperty("java.io.tmpdir"), token, "Exercise-Details-something.json").toFile(); metadata.getParentFile().mkdirs(); metadata.createNewFile(); Group group = new Group(); - Repository jgitRepo = FileRepositoryBuilder.create(new File("tmp-import/" + token, ".git")); + Repository jgitRepo = FileRepositoryBuilder.create(Paths.get(System.getProperty("java.io.tmpdir"), token, ".git").toFile()); // mocks doNothing().when(gitlabService).setJGitDefaultAuth(); doReturn(group).when(gitlabService).getGroupById(gitlabGroup); doReturn("repoUrl").when(gitlabService).createRepository(group, artemisExerciseInfo.getTitle()); doReturn(jgitRepo).when(gitlabService).checkoutRepo("repoUrl"); - doNothing().when(gitlabService).commitAndPushToRepo(jgitRepo, new File("tmp-import", token)); + doNothing().when(gitlabService).commitAndPushToRepo(jgitRepo, new File(System.getProperty("java.io.tmpdir"), token)); exerciseService.importExercise(artemisExerciseInfo, token, gitlabGroup); // asserts verify(gitlabService, times(1)).createRepository(group, artemisExerciseInfo.getTitle()); - verify(gitlabService, times(1)).commitAndPushToRepo(jgitRepo, new File("tmp-import", token)); + verify(gitlabService, times(1)).commitAndPushToRepo(jgitRepo, new File(System.getProperty("java.io.tmpdir"), token)); } @Test public void testApplyExerciseInfoChanges() throws Exception { - File metadata = new File("tmp-import/" + token, "metadata.yaml"); + File metadata = Paths.get(System.getProperty("java.io.tmpdir"), token, "metadata.yaml").toFile(); metadata.getParentFile().mkdirs(); metadata.createNewFile(); @@ -103,7 +104,7 @@ public class ExerciseServiceIT { @Test public void testGetArtemisExerciseInfo() throws Exception { - File metadata = new File("tmp-import/" + token, "Exercise-Details-something.json"); + File metadata = Paths.get(System.getProperty("java.io.tmpdir"), token, "Exercise-Details-something.json").toFile(); metadata.getParentFile().mkdirs(); metadata.createNewFile(); FileWriter writer = new FileWriter(metadata, StandardCharsets.UTF_8); @@ -145,7 +146,7 @@ public class ExerciseServiceIT { @Test public void testGetArtemisExerciseInfo_onlyMetadata() throws Exception { - File metadata = new File("tmp-import/" + token, "Exercise-Details-something.json"); + File metadata = Paths.get(System.getProperty("java.io.tmpdir"), token, "Exercise-Details-something.json").toFile(); metadata.getParentFile().mkdirs(); metadata.createNewFile(); FileWriter writer = new FileWriter(metadata, StandardCharsets.UTF_8);