31
31
import org .springframework .boot .build .bom .Library .ProhibitedVersion ;
32
32
import org .springframework .boot .build .bom .Library .VersionAlignment ;
33
33
import org .springframework .boot .build .bom .bomr .version .DependencyVersion ;
34
+ import org .springframework .boot .build .properties .BuildType ;
34
35
35
36
import static org .assertj .core .api .Assertions .assertThat ;
36
37
42
43
*/
43
44
class AntoraAsciidocAttributesTests {
44
45
46
+ @ Test
47
+ void buildTypeWhenOpenSource () {
48
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType .OPEN_SOURCE , null ,
49
+ mockDependencyVersions (), null );
50
+ assertThat (attributes .get ()).containsEntry ("build-type" , "opensource" );
51
+ }
52
+
53
+ @ Test
54
+ void buildTypeWhenCommercial () {
55
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType .COMMERCIAL , null ,
56
+ mockDependencyVersions (), null );
57
+ assertThat (attributes .get ()).containsEntry ("build-type" , "commercial" );
58
+ }
59
+
45
60
@ Test
46
61
void githubRefWhenReleasedVersionIsTag () {
47
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
62
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
48
63
mockDependencyVersions (), null );
49
64
assertThat (attributes .get ()).containsEntry ("github-ref" , "v1.2.3" );
50
65
}
51
66
52
67
@ Test
53
68
void githubRefWhenLatestSnapshotVersionIsMainBranch () {
54
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
55
- mockDependencyVersions (), null );
69
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true ,
70
+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
56
71
assertThat (attributes .get ()).containsEntry ("github-ref" , "main" );
57
72
}
58
73
59
74
@ Test
60
75
void githubRefWhenOlderSnapshotVersionIsBranch () {
61
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , false , null ,
62
- mockDependencyVersions (), null );
76
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , false ,
77
+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
63
78
assertThat (attributes .get ()).containsEntry ("github-ref" , "1.2.x" );
64
79
}
65
80
66
81
@ Test
67
82
void githubRefWhenOlderSnapshotHotFixVersionIsBranch () {
68
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false , null ,
69
- mockDependencyVersions (), null );
83
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false ,
84
+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
70
85
assertThat (attributes .get ()).containsEntry ("github-ref" , "1.2.3.x" );
71
86
}
72
87
73
88
@ Test
74
89
void versionReferenceFromLibrary () {
75
90
Library library = mockLibrary (Collections .emptyMap ());
76
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false , List . of ( library ),
77
- mockDependencyVersions (), null );
91
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false ,
92
+ BuildType . OPEN_SOURCE , List . of ( library ), mockDependencyVersions (), null );
78
93
assertThat (attributes .get ()).containsEntry ("version-spring-framework" , "1.2.3" );
79
94
}
80
95
81
96
@ Test
82
97
void versionReferenceFromSpringDataDependencyReleaseVersion () {
83
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
98
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
84
99
mockDependencyVersions ("3.2.5" ), null );
85
100
assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-docs" , "3.2" );
86
101
assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-javadoc" , "3.2.x" );
87
102
}
88
103
89
104
@ Test
90
105
void versionReferenceFromSpringDataDependencySnapshotVersion () {
91
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
106
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
92
107
mockDependencyVersions ("3.2.0-SNAPSHOT" ), null );
93
108
assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-docs" , "3.2-SNAPSHOT" );
94
109
assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-javadoc" , "3.2.x" );
95
110
}
96
111
97
112
@ Test
98
113
void versionNativeBuildTools () {
99
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
114
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
100
115
mockDependencyVersions (), Map .of ("nativeBuildToolsVersion" , "3.4.5" ));
101
116
assertThat (attributes .get ()).containsEntry ("version-native-build-tools" , "3.4.5" );
102
117
}
103
118
104
119
@ Test
105
120
void urlArtifactRepositoryWhenRelease () {
106
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
121
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
107
122
mockDependencyVersions (), null );
108
123
assertThat (attributes .get ()).containsEntry ("url-artifact-repository" , "https://repo.maven.apache.org/maven2" );
109
124
}
110
125
111
126
@ Test
112
127
void urlArtifactRepositoryWhenMilestone () {
113
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , null ,
114
- mockDependencyVersions (), null );
128
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , BuildType . OPEN_SOURCE ,
129
+ null , mockDependencyVersions (), null );
115
130
assertThat (attributes .get ()).containsEntry ("url-artifact-repository" , "https://repo.spring.io/milestone" );
116
131
}
117
132
118
133
@ Test
119
134
void urlArtifactRepositoryWhenSnapshot () {
120
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
121
- mockDependencyVersions (), null );
135
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true ,
136
+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
122
137
assertThat (attributes .get ()).containsEntry ("url-artifact-repository" , "https://repo.spring.io/snapshot" );
123
138
}
124
139
125
140
@ Test
126
- void artifactReleaseTypeWhenRelease () {
127
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
141
+ void artifactReleaseTypeWhenOpenSourceRelease () {
142
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
128
143
mockDependencyVersions (), null );
129
144
assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "release" );
145
+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "opensource-release" );
130
146
}
131
147
132
148
@ Test
133
- void artifactReleaseTypeWhenMilestone () {
134
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , null ,
135
- mockDependencyVersions (), null );
149
+ void artifactReleaseTypeWhenOpenSourceMilestone () {
150
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , BuildType . OPEN_SOURCE ,
151
+ null , mockDependencyVersions (), null );
136
152
assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "milestone" );
153
+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "opensource-milestone" );
137
154
}
138
155
139
156
@ Test
140
- void artifactReleaseTypeWhenSnapshot () {
141
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
157
+ void artifactReleaseTypeWhenOpenSourceSnapshot () {
158
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true ,
159
+ BuildType .OPEN_SOURCE , null , mockDependencyVersions (), null );
160
+ assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "snapshot" );
161
+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "opensource-snapshot" );
162
+ }
163
+
164
+ @ Test
165
+ void artifactReleaseTypeWhenCommercialRelease () {
166
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType .COMMERCIAL , null ,
167
+ mockDependencyVersions (), null );
168
+ assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "release" );
169
+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "commercial-release" );
170
+ }
171
+
172
+ @ Test
173
+ void artifactReleaseTypeWhenCommercialMilestone () {
174
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , BuildType .COMMERCIAL , null ,
142
175
mockDependencyVersions (), null );
176
+ assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "milestone" );
177
+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "commercial-milestone" );
178
+ }
179
+
180
+ @ Test
181
+ void artifactReleaseTypeWhenCommercialSnapshot () {
182
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , BuildType .COMMERCIAL ,
183
+ null , mockDependencyVersions (), null );
143
184
assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "snapshot" );
185
+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "commercial-snapshot" );
144
186
}
145
187
146
188
@ Test
@@ -149,16 +191,16 @@ void urlLinksFromLibrary() {
149
191
links .put ("site" , (version ) -> "https://example.com/site/" + version );
150
192
links .put ("docs" , (version ) -> "https://example.com/docs/" + version );
151
193
Library library = mockLibrary (links );
152
- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false , List . of ( library ),
153
- mockDependencyVersions (), null );
194
+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false ,
195
+ BuildType . OPEN_SOURCE , List . of ( library ), mockDependencyVersions (), null );
154
196
assertThat (attributes .get ()).containsEntry ("url-spring-framework-site" , "https://example.com/site/1.2.3" )
155
197
.containsEntry ("url-spring-framework-docs" , "https://example.com/docs/1.2.3" );
156
198
}
157
199
158
200
@ Test
159
201
void linksFromProperties () {
160
- Map <String , String > attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
161
- mockDependencyVersions (), null )
202
+ Map <String , String > attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , BuildType . OPEN_SOURCE ,
203
+ null , mockDependencyVersions (), null )
162
204
.get ();
163
205
assertThat (attributes ).containsEntry ("include-java" , "ROOT:example$java/org/springframework/boot/docs" );
164
206
assertThat (attributes ).containsEntry ("url-spring-data-cassandra-site" ,
0 commit comments