### Question:
MergeSourceSetFolders extends IncrementalTask { @VisibleForTesting List<AssetSet> computeAssetSetList() { List<AssetSet> assetSetList; List<AssetSet> assetSets = assetSetSupplier.get(); if (copyApk == null && shadersOutputDir == null && ignoreAssets == null && libraries == null) { assetSetList = assetSets; } else { int size = assetSets.size() + 3; if (libraries != null) { size += libraries.getArtifacts().size(); } assetSetList = Lists.newArrayListWithExpectedSize(size); if (libraries != null) { Set<ResolvedArtifactResult> libArtifacts = libraries.getArtifacts(); for (ResolvedArtifactResult artifact : libArtifacts) { AssetSet assetSet = new AssetSet(ProcessApplicationManifest.getArtifactName(artifact)); assetSet.addSource(artifact.getFile()); assetSetList.add(0, assetSet); } } List<File> generatedAssetFolders = Lists.newArrayList(); if (shadersOutputDir != null) { generatedAssetFolders.addAll(shadersOutputDir.getFiles()); } if (copyApk != null) { generatedAssetFolders.addAll(copyApk.getFiles()); } final AssetSet mainAssetSet = assetSets.get(0); assert mainAssetSet.getConfigName().equals(BuilderConstants.MAIN); mainAssetSet.addSources(generatedAssetFolders); assetSetList.addAll(assetSets); } if (ignoreAssets != null) { for (AssetSet set : assetSetList) { set.setIgnoredPatterns(ignoreAssets); } } return assetSetList; } @Inject  MergeSourceSetFolders(WorkerExecutor workerExecutor); @OutputDirectory Provider<Directory> getOutputDir(); @Optional @InputFiles @PathSensitive(PathSensitivity.RELATIVE) FileCollection getLibraries(); @VisibleForTesting void setLibraries(@NonNull ArtifactCollection libraries); @InputFiles @Optional @PathSensitive(PathSensitivity.RELATIVE) BuildableArtifact getShadersOutputDir(); @InputFiles @Optional @PathSensitive(PathSensitivity.RELATIVE) FileCollection getCopyApk(); @Input @Optional String getIgnoreAssets(); @InputFiles @PathSensitive(PathSensitivity.RELATIVE) Collection<File> getSourceFolderInputs();  }### Answer:
@Test public void singleSetWithSingleFile() throws Exception { File file = new File("src/main"); AssetSet mainSet = createAssetSet(folderSets, BuilderConstants.MAIN, file); assertThat(task.computeAssetSetList()).containsExactly(mainSet); }
@Test public void singleSetWithMultiFiles() throws Exception { File file = new File("src/main"); File file2 = new File("src/main2"); AssetSet mainSet = createAssetSet(folderSets, BuilderConstants.MAIN, file, file2); assertThat(task.computeAssetSetList()).containsExactly(mainSet); }
@Test public void twoSetsWithSingleFile() throws Exception { File file = new File("src/main"); AssetSet mainSet = createAssetSet(folderSets, BuilderConstants.MAIN, file); File file2 = new File("src/debug"); AssetSet debugSet = createAssetSet(folderSets, "debug", file2); assertThat(task.computeAssetSetList()).containsExactly(mainSet, debugSet); }
@Test public void singleSetWithRenderscript() throws Exception { File file = new File("src/main"); AssetSet mainSet = createAssetSet(folderSets, BuilderConstants.MAIN, file); File shaderFile = new File("shader"); setBuildableArtifact(task::setShadersOutputDir, shaderFile); assertThat(task.computeAssetSetList()).containsExactly(mainSet); assertThat(mainSet.getSourceFiles()).containsExactly(file, shaderFile); }
@Test public void singleSetWithGeneratedRes() throws Exception { File file = new File("src/main"); AssetSet mainSet = createAssetSet(folderSets, BuilderConstants.MAIN, file); File copyApkFile = new File("copyApk"); setFileCollection(task::setCopyApk, copyApkFile); assertThat(task.computeAssetSetList()).containsExactly(mainSet); assertThat(mainSet.getSourceFiles()).containsExactly(file, copyApkFile); }