25
25
26
26
package jenkins .scm .api ;
27
27
28
+ import static org .hamcrest .MatcherAssert .assertThat ;
29
+ import static org .hamcrest .Matchers .hasSize ;
30
+ import static org .hamcrest .Matchers .is ;
31
+
28
32
import edu .umd .cs .findbugs .annotations .NonNull ;
29
33
import java .util .Arrays ;
30
34
import java .util .Collections ;
38
42
import jenkins .scm .impl .UncategorizedSCMHeadCategory ;
39
43
import jenkins .util .NonLocalizable ;
40
44
import org .hamcrest .Matchers ;
41
- import org .junit .Test ;
45
+ import org .junit .jupiter . api . Test ;
42
46
import org .jvnet .localizer .Localizable ;
43
47
44
- import static org .hamcrest .MatcherAssert .assertThat ;
45
- import static org .hamcrest .Matchers .hasSize ;
46
- import static org .hamcrest .Matchers .is ;
48
+ class SCMCategoryTest {
47
49
48
- public class SCMCategoryTest {
49
50
@ Test
50
- public void toDisplayName () throws Exception {
51
- assertThat (SCMCategory .toDisplayName (UncategorizedSCMHeadCategory .DEFAULT , ChangeRequestSCMHeadCategory .DEFAULT ,
52
- TagSCMHeadCategory .DEFAULT ).toString (
53
- Locale .ENGLISH ), is ("Branches / Change requests / Tags" ));
54
- assertThat (SCMCategory .toDisplayName (UncategorizedSCMHeadCategory .DEFAULT ,
55
- TagSCMHeadCategory .DEFAULT ).toString (
56
- Locale .ENGLISH ), is ("Branches / Tags" ));
57
- assertThat (SCMCategory .toDisplayName (UncategorizedSCMHeadCategory .DEFAULT ).toString (
58
- Locale .ENGLISH ), is ("Branches" ));
51
+ void toDisplayName () {
52
+ assertThat (
53
+ SCMCategory .toDisplayName (
54
+ UncategorizedSCMHeadCategory .DEFAULT ,
55
+ ChangeRequestSCMHeadCategory .DEFAULT ,
56
+ TagSCMHeadCategory .DEFAULT )
57
+ .toString (Locale .ENGLISH ),
58
+ is ("Branches / Change requests / Tags" ));
59
+ assertThat (
60
+ SCMCategory .toDisplayName (UncategorizedSCMHeadCategory .DEFAULT , TagSCMHeadCategory .DEFAULT )
61
+ .toString (Locale .ENGLISH ),
62
+ is ("Branches / Tags" ));
63
+ assertThat (
64
+ SCMCategory .toDisplayName (UncategorizedSCMHeadCategory .DEFAULT ).toString (Locale .ENGLISH ),
65
+ is ("Branches" ));
59
66
}
60
67
61
68
@ Test
62
- public void toDisplayName1 () throws Exception {
63
- assertThat (SCMCategory .toDisplayName (Arrays .asList (ChangeRequestSCMHeadCategory .DEFAULT ,
64
- TagSCMHeadCategory .DEFAULT , UncategorizedSCMHeadCategory .DEFAULT )).toString (
65
- Locale .ENGLISH ), is ("Branches / Change requests / Tags" ));
66
-
69
+ void toDisplayName1 () {
70
+ assertThat (
71
+ SCMCategory .toDisplayName (Arrays .asList (
72
+ ChangeRequestSCMHeadCategory .DEFAULT ,
73
+ TagSCMHeadCategory .DEFAULT ,
74
+ UncategorizedSCMHeadCategory .DEFAULT ))
75
+ .toString (Locale .ENGLISH ),
76
+ is ("Branches / Change requests / Tags" ));
67
77
}
68
78
69
79
@ Test
70
- public void toShortUrl () throws Exception {
71
- assertThat (SCMCategory .toShortUrl (UncategorizedSCMHeadCategory .DEFAULT , ChangeRequestSCMHeadCategory .DEFAULT ,
72
- TagSCMHeadCategory .DEFAULT ), is ("change-requests_default_tags" ));
73
-
80
+ void toShortUrl () {
81
+ assertThat (
82
+ SCMCategory .toShortUrl (
83
+ UncategorizedSCMHeadCategory .DEFAULT ,
84
+ ChangeRequestSCMHeadCategory .DEFAULT ,
85
+ TagSCMHeadCategory .DEFAULT ),
86
+ is ("change-requests_default_tags" ));
74
87
}
75
88
76
89
@ Test
77
- public void toShortUrl1 () throws Exception {
78
- assertThat (SCMCategory .toShortUrl (Arrays .asList (ChangeRequestSCMHeadCategory .DEFAULT ,
79
- TagSCMHeadCategory .DEFAULT , UncategorizedSCMHeadCategory .DEFAULT )), is ("change-requests_default_tags" ));
80
- assertThat (SCMCategory .toShortUrl (Arrays .asList (TagSCMHeadCategory .DEFAULT , UncategorizedSCMHeadCategory .DEFAULT )), is ("default_tags" ));
90
+ void toShortUrl1 () {
91
+ assertThat (
92
+ SCMCategory .toShortUrl (Arrays .asList (
93
+ ChangeRequestSCMHeadCategory .DEFAULT ,
94
+ TagSCMHeadCategory .DEFAULT ,
95
+ UncategorizedSCMHeadCategory .DEFAULT )),
96
+ is ("change-requests_default_tags" ));
97
+ assertThat (
98
+ SCMCategory .toShortUrl (Arrays .asList (TagSCMHeadCategory .DEFAULT , UncategorizedSCMHeadCategory .DEFAULT )),
99
+ is ("default_tags" ));
81
100
assertThat (SCMCategory .toShortUrl (Collections .singletonList (TagSCMHeadCategory .DEFAULT )), is ("tags" ));
82
-
83
101
}
84
102
85
103
@ Test
86
- public void group () throws Exception {
104
+ void group () {
87
105
UncategorizedSCMHeadCategory u1 = UncategorizedSCMHeadCategory .DEFAULT ;
88
106
UncategorizedSCMHeadCategory u2 = new UncategorizedSCMHeadCategory (new NonLocalizable ("foo" ));
89
107
ChangeRequestSCMHeadCategory c1 = ChangeRequestSCMHeadCategory .DEFAULT ;
90
108
ChangeRequestSCMHeadCategory c2 = new ChangeRequestSCMHeadCategory (new NonLocalizable ("bar" ));
91
109
ChangeRequestSCMHeadCategory c3 = new ChangeRequestSCMHeadCategory (new NonLocalizable ("manchu" ));
92
110
Map <String , List <SCMHeadCategory >> result = SCMCategory .group (u1 , c1 , c2 , c3 , u2 );
93
111
assertThat (result .entrySet (), hasSize (2 ));
94
- assertThat (result .get ("default" ), Matchers .< SCMCategory > containsInAnyOrder (u1 , u2 ));
95
- assertThat (result .get ("change-requests" ), Matchers .< SCMCategory > containsInAnyOrder (c1 , c2 , c3 ));
112
+ assertThat (result .get ("default" ), Matchers .containsInAnyOrder (u1 , u2 ));
113
+ assertThat (result .get ("change-requests" ), Matchers .containsInAnyOrder (c1 , c2 , c3 ));
96
114
}
97
115
98
116
@ Test
99
- public void group1 () throws Exception {
117
+ void group1 () {
100
118
UncategorizedSCMHeadCategory u1 = UncategorizedSCMHeadCategory .DEFAULT ;
101
119
UncategorizedSCMHeadCategory u2 = new UncategorizedSCMHeadCategory (new NonLocalizable ("foo" ));
102
120
ChangeRequestSCMHeadCategory c1 = ChangeRequestSCMHeadCategory .DEFAULT ;
@@ -105,30 +123,39 @@ public void group1() throws Exception {
105
123
TagSCMHeadCategory t1 = new TagSCMHeadCategory (new NonLocalizable ("foomanchu" ));
106
124
Map <String , List <SCMHeadCategory >> result = SCMCategory .group (Arrays .asList (u1 , c1 , t1 , c2 , c3 , u2 ));
107
125
assertThat (result .entrySet (), hasSize (3 ));
108
- assertThat (result .get ("default" ), Matchers .<SCMCategory >containsInAnyOrder (u1 , u2 ));
109
- assertThat (result .get ("change-requests" ), Matchers .<SCMCategory >containsInAnyOrder (c1 , c2 , c3 ));
110
- assertThat (result .get ("tags" ), Matchers .<SCMCategory >contains (t1 ));
111
-
126
+ assertThat (result .get ("default" ), Matchers .containsInAnyOrder (u1 , u2 ));
127
+ assertThat (result .get ("change-requests" ), Matchers .containsInAnyOrder (c1 , c2 , c3 ));
128
+ assertThat (result .get ("tags" ), Matchers .contains (t1 ));
112
129
}
113
130
114
131
@ Test
115
- public void getName () throws Exception {
116
- assertThat (new MySCMCategory ("foomanchu" , new NonLocalizable ("Fu Manchu" ), new NonLocalizable ("Fu Manchu" )).getName (), is ("foomanchu" ));
132
+ void getName () {
133
+ assertThat (
134
+ new MySCMCategory ("foomanchu" , new NonLocalizable ("Fu Manchu" ), new NonLocalizable ("Fu Manchu" ))
135
+ .getName (),
136
+ is ("foomanchu" ));
117
137
}
118
138
119
139
@ Test
120
- public void getDisplayName () throws Exception {
121
- assertThat (new MySCMCategory ("foomanchu" , new NonLocalizable ("Fu Manchu" ), new NonLocalizable ("Fu Manchu" )).getDisplayName ().toString (Locale .ENGLISH ), is ("Fu Manchu" ));
140
+ void getDisplayName () {
141
+ assertThat (
142
+ new MySCMCategory ("foomanchu" , new NonLocalizable ("Fu Manchu" ), new NonLocalizable ("Fu Manchu" ))
143
+ .getDisplayName ()
144
+ .toString (Locale .ENGLISH ),
145
+ is ("Fu Manchu" ));
122
146
}
123
147
124
148
@ Test
125
- public void defaultDisplayName () throws Exception {
126
- assertThat (new MySCMCategory ("foomanchu" , null , new NonLocalizable ("Fu Manchu" ))
127
- .getDisplayName ().toString (Locale .ENGLISH ), is ("Fu Manchu" ));
149
+ void defaultDisplayName () {
150
+ assertThat (
151
+ new MySCMCategory ("foomanchu" , null , new NonLocalizable ("Fu Manchu" ))
152
+ .getDisplayName ()
153
+ .toString (Locale .ENGLISH ),
154
+ is ("Fu Manchu" ));
128
155
}
129
156
130
157
@ Test
131
- public void isMatch () throws Exception {
158
+ void isMatch () {
132
159
UncategorizedSCMHeadCategory u = UncategorizedSCMHeadCategory .DEFAULT ;
133
160
ChangeRequestSCMHeadCategory c = ChangeRequestSCMHeadCategory .DEFAULT ;
134
161
TagSCMHeadCategory t = TagSCMHeadCategory .DEFAULT ;
@@ -173,12 +200,11 @@ public SCMHead getTarget() {
173
200
assertThat (t .isMatch (mh , Arrays .asList (u , c , t )), is (false ));
174
201
assertThat (t .isMatch (ch , Arrays .asList (c , u , t )), is (false ));
175
202
assertThat (t .isMatch (th , Arrays .asList (c , u , t )), is (true ));
176
-
177
203
}
178
204
179
205
private static class MySCMCategory extends SCMCategory <Object > {
180
206
181
- private NonLocalizable defaultDisplayName ;
207
+ private final NonLocalizable defaultDisplayName ;
182
208
183
209
public MySCMCategory (String name , NonLocalizable displayName , NonLocalizable defaultDisplayName ) {
184
210
super (name , displayName );
0 commit comments