diff options
author | Thibault Gagnaux <tgagnaux@gmail.com> | 2022-02-09 10:43:29 +0100 |
---|---|---|
committer | Thibault Gagnaux <tgagnaux@gmail.com> | 2022-02-09 10:43:29 +0100 |
commit | 43ee2210fa07f42a13ac6879ae167db6d2729742 (patch) | |
tree | 722fd5a79b230a927234601d74581fdaa9c3b700 /src/functionalTest/java/ch/fhnw/thga/gradleplugins/DownloadFregeCompilerFunctionalTest.java | |
parent | 47f99d65a09660863cb5d6b25b239ead3389f3ac (diff) | |
download | frege-gradle-plugin-43ee2210fa07f42a13ac6879ae167db6d2729742.tar.gz frege-gradle-plugin-43ee2210fa07f42a13ac6879ae167db6d2729742.tar.bz2 frege-gradle-plugin-43ee2210fa07f42a13ac6879ae167db6d2729742.zip |
refactor: introduces staged builder patterns for frege project setup
(WIP)
Diffstat (limited to 'src/functionalTest/java/ch/fhnw/thga/gradleplugins/DownloadFregeCompilerFunctionalTest.java')
-rw-r--r-- | src/functionalTest/java/ch/fhnw/thga/gradleplugins/DownloadFregeCompilerFunctionalTest.java | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/DownloadFregeCompilerFunctionalTest.java b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/DownloadFregeCompilerFunctionalTest.java new file mode 100644 index 0000000..58f6222 --- /dev/null +++ b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/DownloadFregeCompilerFunctionalTest.java @@ -0,0 +1,101 @@ +package ch.fhnw.thga.gradleplugins; + +import static ch.fhnw.thga.gradleplugins.FregeExtension.DEFAULT_DOWNLOAD_DIRECTORY; +import static ch.fhnw.thga.gradleplugins.FregePlugin.SETUP_FREGE_TASK_NAME; +import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.createFregeGradleProject; +import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.createFregeSection; +import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.runGradleTask; +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.nio.file.Paths; + +import org.gradle.api.Project; +import org.gradle.testkit.runner.BuildResult; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.IndicativeSentencesGeneration; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import ch.fhnw.thga.gradleplugins.fregeproject.FregeProjectBuilder; +import ch.fhnw.thga.gradleplugins.fregeproject.ProjectRoot; + +class DownloadFregeCompilerFunctionalTest +{ + private static FregeDTOBuilder FREGE_BUILDER = FregeDTOBuilder.getInstance(); + private static ProjectRoot FREGE_PROJECT_BUILDER = FregeProjectBuilder.getInstance(); + + @Nested + @IndicativeSentencesGeneration(separator = " -> ", generator = DisplayNameGenerator.ReplaceUnderscores.class) + class Setup_frege_task_works { + @Test + void given_minimal_build_file_config(@TempDir File testProjectDir) throws Exception + { + String minimalBuildFileConfig = createFregeSection( + FREGE_BUILDER + .version("'3.25.84'") + .release("'3.25alpha'") + .build() + ); + + Project project = FREGE_PROJECT_BUILDER + .projectRoot(testProjectDir) + .buildFile(minimalBuildFileConfig) + .build(); + + BuildResult result = runGradleTask(testProjectDir, SETUP_FREGE_TASK_NAME); + + assertTrue( + project + .getTasks() + .getByName(SETUP_FREGE_TASK_NAME) instanceof SetupFregeTask + ); + assertEquals(SUCCESS, result.task(":" + SETUP_FREGE_TASK_NAME).getOutcome()); + assertTrue( + testProjectDir + .toPath() + .resolve(Paths.get(DEFAULT_DOWNLOAD_DIRECTORY, "frege3.25.84.jar")) + .toFile() + .exists() + ); + } + + @Test + void given_custom_frege_compiler_download_directory_in_build_file_config( + @TempDir File testProjectDir) + throws Exception + { + String buildFileConfigWithCustomDownloadDir = createFregeSection( + FREGE_BUILDER + .version("'3.25.84'") + .release("'3.25alpha'") + .compilerDownloadDir("layout.projectDirectory.dir('dist')") + .build() + ); + + Project project = FREGE_PROJECT_BUILDER + .projectRoot(testProjectDir) + .buildFile(buildFileConfigWithCustomDownloadDir) + .build(); + + BuildResult result = runGradleTask(testProjectDir, SETUP_FREGE_TASK_NAME); + + assertTrue( + project + .getTasks() + .getByName(SETUP_FREGE_TASK_NAME) instanceof SetupFregeTask + ); + assertEquals(SUCCESS, result.task(":" + SETUP_FREGE_TASK_NAME).getOutcome()); + assertTrue( + testProjectDir + .toPath() + .resolve(Paths.get("dist", "frege3.25.84.jar")) + .toFile() + .exists() + ); + } + } +}
\ No newline at end of file |