// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/CpdXmlFileReportImpl.java
// public abstract class CpdXmlFileReportImpl extends TaskGeneratedSingleFileReport implements CpdXmlFileReport {
// 
//     private String encoding;
// 
//     @Inject
//     public CpdXmlFileReportImpl(String name, Task task) {
//         super(name, task);
//     }
// 
//     @Override
//     public String getEncoding() {
//         return encoding;
//     }
// 
//     @Override
//     public void setEncoding(String encoding) {
//         this.encoding = encoding;
//     }
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/GradleExtension.java
// public class GradleExtension implements BeforeEachCallback, ParameterResolver {
// 
//     private static final Map<Class<?>, Function<GradleExtension, ?>> parameterMap =
//             ImmutableMap.<Class<?>, Function<GradleExtension, ?>>builder()
//                     .put(Project.class, (GradleExtension ex) -> ex.project)
//                     .put(Configuration.class, (GradleExtension ex) -> ex.project.getConfigurations().getByName("cpd"))
//                     .put(CpdExtension.class, (GradleExtension ex) -> ex.project.getExtensions().getByType(CpdExtension.class))
//                     // Use TaskProvider because of lazy configuration, otherwise additional configuration within in test is not recognized
//                     .put(TaskProvider.class, (GradleExtension ex) -> ex.project.getTasks().named("cpdCheck"))
//                     .build();
//     private Project project;
// 
//     @Override
//     public void beforeEach(ExtensionContext context) {
//         project = ProjectBuilder.builder().build();
//         project.getPlugins().apply(CpdPlugin.class);
//     }
// 
//     @Override
//     public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
//         return parameterMap.containsKey(parameterContext.getParameter().getType());
// 
//     }
// 
//     @Override
//     public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
//         return parameterMap.get(parameterContext.getParameter().getType()).apply(this);
//     }
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestFileResolver.java
// public static List<File> createProjectFiles(Project project, String... files) {
//     return Arrays.stream(files).map(filePath -> {
//         File file = project.file(filePath);
//         try {
//             if (file.isDirectory()) {
//                 Files.createDirectories(file.toPath());
//             } else {
//                 Files.createDirectories(file.toPath().getParent());
//                 Files.createFile(file.toPath());
//             }
//         } catch (IOException e) {
//             throw new UncheckedIOException(String.format("Exception while creating file %s", file), e);
//         }
//         return file;
//     }).collect(Collectors.toList());
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestFileResolver.java
// public static File testFile(Lang lang, String relativePath) {
//     String resourceName = String.format("/test-data/%s/%s", lang.folder, relativePath);
//     URL resource = TestFileResolver.class.getResource(resourceName);
//     assertThat(resource).as("%s not found on classpath.", resourceName).isNotNull();
// 
//     File file = new File(resource.getPath());
//     assertThat(file).as("Could not find file for %s.", resourceName).isNotNull();
//     assertThat(file.exists()).as("%s does not exist.", file).isTrue();
//     return file;
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestFileResolver.java
// public static List<File> testFilesRecurseIn(Lang lang, String... relativePaths) {
//     return Arrays.stream(relativePaths).flatMap(relativePath -> {
//         Path filePath = testFile(lang, relativePath).toPath();
//         if (Files.isDirectory(filePath)) {
//             try {
//                 return Files.find(filePath, Integer.MAX_VALUE, (path, fileAttr) -> fileAttr.isRegularFile()).map(Path::toFile);
//             } catch (IOException e) {
//                 throw new UncheckedIOException(String.format("Exception while recursively search for files in %s", relativePath), e);
//             }
//         }
//         return Stream.empty();
//     }).collect(Collectors.toList());
// }


import java.io.File;
import java.util.List;
import de.aaschmid.gradle.plugins.cpd.internal.CpdXmlFileReportImpl;
import de.aaschmid.gradle.plugins.cpd.test.GradleExtension;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.FileSystemLocation;
import org.gradle.api.file.FileSystemLocationProperty;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.TaskProvider;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.Lang.JAVA;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.createProjectFiles;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.testFile;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.testFilesRecurseIn;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.params.provider.Arguments.of;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package de.aaschmid.gradle.plugins.cpd;




@ExtendWith(GradleExtension.class)
class CpdTest {

// Path: src/main/java/de/aaschmid/gradle/plugins/cpd/internal/CpdXmlFileReportImpl.java
// public abstract class CpdXmlFileReportImpl extends TaskGeneratedSingleFileReport implements CpdXmlFileReport {
// 
//     private String encoding;
// 
//     @Inject
//     public CpdXmlFileReportImpl(String name, Task task) {
//         super(name, task);
//     }
// 
//     @Override
//     public String getEncoding() {
//         return encoding;
//     }
// 
//     @Override
//     public void setEncoding(String encoding) {
//         this.encoding = encoding;
//     }
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/GradleExtension.java
// public class GradleExtension implements BeforeEachCallback, ParameterResolver {
// 
//     private static final Map<Class<?>, Function<GradleExtension, ?>> parameterMap =
//             ImmutableMap.<Class<?>, Function<GradleExtension, ?>>builder()
//                     .put(Project.class, (GradleExtension ex) -> ex.project)
//                     .put(Configuration.class, (GradleExtension ex) -> ex.project.getConfigurations().getByName("cpd"))
//                     .put(CpdExtension.class, (GradleExtension ex) -> ex.project.getExtensions().getByType(CpdExtension.class))
//                     // Use TaskProvider because of lazy configuration, otherwise additional configuration within in test is not recognized
//                     .put(TaskProvider.class, (GradleExtension ex) -> ex.project.getTasks().named("cpdCheck"))
//                     .build();
//     private Project project;
// 
//     @Override
//     public void beforeEach(ExtensionContext context) {
//         project = ProjectBuilder.builder().build();
//         project.getPlugins().apply(CpdPlugin.class);
//     }
// 
//     @Override
//     public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
//         return parameterMap.containsKey(parameterContext.getParameter().getType());
// 
//     }
// 
//     @Override
//     public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
//         return parameterMap.get(parameterContext.getParameter().getType()).apply(this);
//     }
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestFileResolver.java
// public static List<File> createProjectFiles(Project project, String... files) {
//     return Arrays.stream(files).map(filePath -> {
//         File file = project.file(filePath);
//         try {
//             if (file.isDirectory()) {
//                 Files.createDirectories(file.toPath());
//             } else {
//                 Files.createDirectories(file.toPath().getParent());
//                 Files.createFile(file.toPath());
//             }
//         } catch (IOException e) {
//             throw new UncheckedIOException(String.format("Exception while creating file %s", file), e);
//         }
//         return file;
//     }).collect(Collectors.toList());
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestFileResolver.java
// public static File testFile(Lang lang, String relativePath) {
//     String resourceName = String.format("/test-data/%s/%s", lang.folder, relativePath);
//     URL resource = TestFileResolver.class.getResource(resourceName);
//     assertThat(resource).as("%s not found on classpath.", resourceName).isNotNull();
// 
//     File file = new File(resource.getPath());
//     assertThat(file).as("Could not find file for %s.", resourceName).isNotNull();
//     assertThat(file.exists()).as("%s does not exist.", file).isTrue();
//     return file;
// }
// 
// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/test/TestFileResolver.java
// public static List<File> testFilesRecurseIn(Lang lang, String... relativePaths) {
//     return Arrays.stream(relativePaths).flatMap(relativePath -> {
//         Path filePath = testFile(lang, relativePath).toPath();
//         if (Files.isDirectory(filePath)) {
//             try {
//                 return Files.find(filePath, Integer.MAX_VALUE, (path, fileAttr) -> fileAttr.isRegularFile()).map(Path::toFile);
//             } catch (IOException e) {
//                 throw new UncheckedIOException(String.format("Exception while recursively search for files in %s", relativePath), e);
//             }
//         }
//         return Stream.empty();
//     }).collect(Collectors.toList());
// }


// Path: src/test/java/de/aaschmid/gradle/plugins/cpd/CpdTest.java
import java.io.File;
import java.util.List;
import de.aaschmid.gradle.plugins.cpd.internal.CpdXmlFileReportImpl;
import de.aaschmid.gradle.plugins.cpd.test.GradleExtension;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.FileSystemLocation;
import org.gradle.api.file.FileSystemLocationProperty;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.TaskProvider;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.Lang.JAVA;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.createProjectFiles;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.testFile;
import static de.aaschmid.gradle.plugins.cpd.test.TestFileResolver.testFilesRecurseIn;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.params.provider.Arguments.of;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

package de.aaschmid.gradle.plugins.cpd;




@ExtendWith(GradleExtension.class)
class CpdTest {

    @Test