|
| 1 | +/* |
| 2 | + * Copyright (C) 2025 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + * License-Filename: LICENSE |
| 18 | + */ |
| 19 | + |
| 20 | +package org.ossreviewtoolkit.plugins.packagemanagers.maven |
| 21 | + |
| 22 | +import io.kotest.core.spec.style.WordSpec |
| 23 | +import io.kotest.engine.spec.tempdir |
| 24 | +import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder |
| 25 | + |
| 26 | +import io.mockk.mockk |
| 27 | + |
| 28 | +class MavenTest : WordSpec({ |
| 29 | + "mapDefinitionFiles()" should { |
| 30 | + "filter out Tycho definition files" { |
| 31 | + val tychoProjectDir1 = tempdir() |
| 32 | + tychoProjectDir1.addTychoExtension() |
| 33 | + val tychoDefinitionFile1 = tychoProjectDir1.resolve("pom.xml").also { it.writeText("pom-tycho1") } |
| 34 | + val tychoSubProjectDir = tychoProjectDir1.resolve("subproject") |
| 35 | + val tychoSubModule = tychoSubProjectDir.resolve("pom.xml") |
| 36 | + val tychoProjectDir2 = tempdir() |
| 37 | + tychoProjectDir2.addTychoExtension() |
| 38 | + val tychoDefinitionFile2 = tychoProjectDir2.resolve("pom.xml").also { it.writeText("pom-tycho2") } |
| 39 | + |
| 40 | + val mavenProjectDir = tempdir() |
| 41 | + val mavenDefinitionFile = mavenProjectDir.resolve("pom.xml").also { it.writeText("pom-maven") } |
| 42 | + val mavenSubProjectDir = mavenProjectDir.resolve("subproject") |
| 43 | + val mavenSubModule = mavenSubProjectDir.resolve("pom.xml") |
| 44 | + |
| 45 | + val definitionFiles = listOf( |
| 46 | + tychoDefinitionFile1, |
| 47 | + mavenDefinitionFile, |
| 48 | + tychoDefinitionFile2, |
| 49 | + mavenSubModule, |
| 50 | + tychoSubModule |
| 51 | + ) |
| 52 | + |
| 53 | + val maven = Maven("Maven", tempdir(), mockk(relaxed = true), mockk(relaxed = true)) |
| 54 | + val mappedDefinitionFiles = maven.mapDefinitionFiles(definitionFiles) |
| 55 | + |
| 56 | + mappedDefinitionFiles shouldContainExactlyInAnyOrder listOf(mavenDefinitionFile, mavenSubModule) |
| 57 | + } |
| 58 | + } |
| 59 | +}) |
0 commit comments