From 790ab5eacc37124f75f623f6268e81b71212b7ae Mon Sep 17 00:00:00 2001 From: Sandra Parsick Date: Tue, 4 Oct 2022 18:34:27 +0200 Subject: [PATCH] add test for multi module project --- .../depsupdate/Bug54MultiModuleProjectIT.kt | 61 +++++++++++++++++++ .../updateOnlyInModule/module1/pom.xml | 23 +++++++ .../updateOnlyInModule/module2/pom.xml | 23 +++++++ .../updateOnlyInModule/pom.xml | 31 ++++++++++ 4 files changed, 138 insertions(+) create mode 100644 src/test/kotlin/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT.kt create mode 100644 src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module1/pom.xml create mode 100644 src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module2/pom.xml create mode 100644 src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/pom.xml diff --git a/src/test/kotlin/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT.kt b/src/test/kotlin/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT.kt new file mode 100644 index 0000000..6a80a5b --- /dev/null +++ b/src/test/kotlin/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT.kt @@ -0,0 +1,61 @@ +package io.github.georgberky.maven.plugins.depsupdate + +import com.soebes.itf.jupiter.extension.MavenGoal +import com.soebes.itf.jupiter.extension.MavenJupiterExtension +import com.soebes.itf.jupiter.extension.MavenTest +import com.soebes.itf.jupiter.maven.MavenExecutionResult +import com.soebes.itf.jupiter.maven.MavenProjectResult +import org.apache.commons.io.FileUtils +import org.assertj.core.api.Assertions.assertThat +import org.eclipse.jgit.api.Git +import org.eclipse.jgit.api.ListBranchCommand +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.io.TempDir +import java.io.File +import java.util.stream.Collectors + +@MavenJupiterExtension +class Bug54MultiModuleProjectIT { + @TempDir + lateinit var remoteRepo: File + + lateinit var repo: Git + + @BeforeEach + internal fun setUp(result: MavenProjectResult) { + FileUtils.copyDirectory(result.targetProjectDirectory, remoteRepo) + + repo = Git.init().setDirectory(remoteRepo).call() + repo.add().addFilepattern(".").call(); + repo.commit() + .setAuthor("Schorsch", "georg@email.com") + .setMessage("Initial commit.") + .call() + + FileUtils.deleteDirectory(result.targetProjectDirectory) + + repo = Git.cloneRepository() + .setURI(remoteRepo.toURI().toString()) + .setDirectory(result.targetProjectDirectory) + .call() + } + + @MavenTest + @MavenGoal("\${project.groupId}:\${project.artifactId}:\${project.version}:update") + fun updateOnlyInModule(result: MavenExecutionResult) { + assertTrue(result.isSuccessful) + + val branchList = repo.branchList() + .setListMode(ListBranchCommand.ListMode.ALL) + .call() + .stream() + .map { it.name } + .collect(Collectors.toList()) + + val updatedBranchNames = branchList.filter { it.startsWith("refs/heads/dependency-update") } + + assertThat(updatedBranchNames).hasSize(2) + } + +} \ No newline at end of file diff --git a/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module1/pom.xml b/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module1/pom.xml new file mode 100644 index 0000000..e52aa76 --- /dev/null +++ b/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module1/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + + io.github.georgberky.maven.plugins.depsupdate + multi-module-test-parent + 0.6.0 + + + native-git-provider-module1 + + + + org.assertj + assertj-core + 3.15.0 + + + + + + diff --git a/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module2/pom.xml b/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module2/pom.xml new file mode 100644 index 0000000..af07a30 --- /dev/null +++ b/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/module2/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + + io.github.georgberky.maven.plugins.depsupdate + multi-module-test-parent + 0.6.0 + + + native-git-provider-module2 + + + + org.junit.jupiter + junit-jupiter + 5.5.2 + + + + + + diff --git a/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/pom.xml b/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/pom.xml new file mode 100644 index 0000000..7b97379 --- /dev/null +++ b/src/test/resources-its/io/github/georgberky/maven/plugins/depsupdate/Bug54MultiModuleProjectIT/updateOnlyInModule/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + + io.github.georgberky.maven.plugins.depsupdate + multi-module-test-parent + 0.6.0 + pom + + + someConnection + someDeveloperConnection + + + + module1 + module2 + + + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + + +