|
| 1 | +/* |
| 2 | + * Copyright 2012-2024 the original author or authors. |
| 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 | + |
| 17 | +package org.springframework.boot.build.bom; |
| 18 | + |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.List; |
| 21 | +import java.util.Map; |
| 22 | +import java.util.function.Function; |
| 23 | + |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | + |
| 26 | +import org.springframework.boot.build.bom.Library.Group; |
| 27 | +import org.springframework.boot.build.bom.Library.LibraryVersion; |
| 28 | +import org.springframework.boot.build.bom.Library.ProhibitedVersion; |
| 29 | +import org.springframework.boot.build.bom.Library.VersionAlignment; |
| 30 | +import org.springframework.boot.build.bom.bomr.version.DependencyVersion; |
| 31 | + |
| 32 | +import static org.assertj.core.api.Assertions.assertThat; |
| 33 | + |
| 34 | +/** |
| 35 | + * Tests for {@link Library}. |
| 36 | + * |
| 37 | + * @author Phillip Webb |
| 38 | + */ |
| 39 | +class LibraryTests { |
| 40 | + |
| 41 | + @Test |
| 42 | + void getLinkRootNameWhenNoneSpecified() { |
| 43 | + String name = "Spring Framework"; |
| 44 | + String calendarName = null; |
| 45 | + LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3")); |
| 46 | + List<Group> groups = Collections.emptyList(); |
| 47 | + List<ProhibitedVersion> prohibitedVersion = Collections.emptyList(); |
| 48 | + boolean considerSnapshots = false; |
| 49 | + VersionAlignment versionAlignment = null; |
| 50 | + String linkRootName = null; |
| 51 | + Map<String, Function<LibraryVersion, String>> links = Collections.emptyMap(); |
| 52 | + Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots, |
| 53 | + versionAlignment, linkRootName, links); |
| 54 | + assertThat(library.getLinkRootName()).isEqualTo("spring-framework"); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + void getLinkRootNameWhenSpecified() { |
| 59 | + String name = "Spring Data BOM"; |
| 60 | + String calendarName = null; |
| 61 | + LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3")); |
| 62 | + List<Group> groups = Collections.emptyList(); |
| 63 | + List<ProhibitedVersion> prohibitedVersion = Collections.emptyList(); |
| 64 | + boolean considerSnapshots = false; |
| 65 | + VersionAlignment versionAlignment = null; |
| 66 | + String linkRootName = "spring-data"; |
| 67 | + Map<String, Function<LibraryVersion, String>> links = Collections.emptyMap(); |
| 68 | + Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots, |
| 69 | + versionAlignment, linkRootName, links); |
| 70 | + assertThat(library.getLinkRootName()).isEqualTo("spring-data"); |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments