From 5967c1ee0f2d33de2b2eceb86a9360759dc5e3cf Mon Sep 17 00:00:00 2001 From: Clayton Walker Date: Tue, 19 Apr 2022 03:09:04 -0600 Subject: [PATCH] Add test to validate test resources directory --- .../plugins/PluginResourceDirectoryTests.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java diff --git a/src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java b/src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java new file mode 100644 index 00000000..4b40ac65 --- /dev/null +++ b/src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java @@ -0,0 +1,55 @@ +package org.gradle.playframework.plugins; + +import org.gradle.api.Project; +import org.gradle.api.file.SourceDirectorySet; +import org.gradle.api.tasks.SourceSet; +import org.gradle.playframework.plugins.internal.PlayPluginHelper; +import org.gradle.testfixtures.ProjectBuilder; +import org.junit.Test; + +import java.io.File; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + +public class PluginResourceDirectoryTests { + @Test + public void testResourcesDirectories() { + // given + Project project = ProjectBuilder + .builder() + .build(); + + // when + project.getPluginManager().apply(PlayPlugin.class); + + SourceSet mainSourceSet = PlayPluginHelper.getMainJavaSourceSet(project); + SourceDirectorySet mainResourcesDirectorySet = mainSourceSet.getResources(); + + // then + assertEquals( + Collections.singleton(new File(project.getProjectDir(), "conf")), + mainResourcesDirectorySet.getSrcDirs() + ); + } + + @Test + public void testTestResourcesDirectories() { + // given + Project project = ProjectBuilder + .builder() + .build(); + + // when + project.getPluginManager().apply(PlayPlugin.class); + + SourceSet testSourceSet = PlayPluginHelper.getTestJavaSourceSet(project); + SourceDirectorySet testResourcesDirectorySet = testSourceSet.getResources(); + + // then + assertEquals( + Collections.singleton(new File(project.getProjectDir(), "test/resources")), + testResourcesDirectorySet.getSrcDirs() + ); + } +}