2525
2626package jenkins .scm .api ;
2727
28+ import static org .hamcrest .MatcherAssert .assertThat ;
29+ import static org .hamcrest .Matchers .hasSize ;
30+ import static org .hamcrest .Matchers .is ;
31+
2832import edu .umd .cs .findbugs .annotations .NonNull ;
2933import java .util .Arrays ;
3034import java .util .Collections ;
3842import jenkins .scm .impl .UncategorizedSCMHeadCategory ;
3943import jenkins .util .NonLocalizable ;
4044import org .hamcrest .Matchers ;
41- import org .junit .Test ;
45+ import org .junit .jupiter . api . Test ;
4246import org .jvnet .localizer .Localizable ;
4347
44- import static org .hamcrest .MatcherAssert .assertThat ;
45- import static org .hamcrest .Matchers .hasSize ;
46- import static org .hamcrest .Matchers .is ;
48+ class SCMCategoryTest {
4749
48- public class SCMCategoryTest {
4950 @ 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" ));
5966 }
6067
6168 @ 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" ));
6777 }
6878
6979 @ 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" ));
7487 }
7588
7689 @ 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" ));
81100 assertThat (SCMCategory .toShortUrl (Collections .singletonList (TagSCMHeadCategory .DEFAULT )), is ("tags" ));
82-
83101 }
84102
85103 @ Test
86- public void group () throws Exception {
104+ void group () {
87105 UncategorizedSCMHeadCategory u1 = UncategorizedSCMHeadCategory .DEFAULT ;
88106 UncategorizedSCMHeadCategory u2 = new UncategorizedSCMHeadCategory (new NonLocalizable ("foo" ));
89107 ChangeRequestSCMHeadCategory c1 = ChangeRequestSCMHeadCategory .DEFAULT ;
90108 ChangeRequestSCMHeadCategory c2 = new ChangeRequestSCMHeadCategory (new NonLocalizable ("bar" ));
91109 ChangeRequestSCMHeadCategory c3 = new ChangeRequestSCMHeadCategory (new NonLocalizable ("manchu" ));
92110 Map <String , List <SCMHeadCategory >> result = SCMCategory .group (u1 , c1 , c2 , c3 , u2 );
93111 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 ));
96114 }
97115
98116 @ Test
99- public void group1 () throws Exception {
117+ void group1 () {
100118 UncategorizedSCMHeadCategory u1 = UncategorizedSCMHeadCategory .DEFAULT ;
101119 UncategorizedSCMHeadCategory u2 = new UncategorizedSCMHeadCategory (new NonLocalizable ("foo" ));
102120 ChangeRequestSCMHeadCategory c1 = ChangeRequestSCMHeadCategory .DEFAULT ;
@@ -105,30 +123,39 @@ public void group1() throws Exception {
105123 TagSCMHeadCategory t1 = new TagSCMHeadCategory (new NonLocalizable ("foomanchu" ));
106124 Map <String , List <SCMHeadCategory >> result = SCMCategory .group (Arrays .asList (u1 , c1 , t1 , c2 , c3 , u2 ));
107125 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 ));
112129 }
113130
114131 @ 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" ));
117137 }
118138
119139 @ 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" ));
122146 }
123147
124148 @ 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" ));
128155 }
129156
130157 @ Test
131- public void isMatch () throws Exception {
158+ void isMatch () {
132159 UncategorizedSCMHeadCategory u = UncategorizedSCMHeadCategory .DEFAULT ;
133160 ChangeRequestSCMHeadCategory c = ChangeRequestSCMHeadCategory .DEFAULT ;
134161 TagSCMHeadCategory t = TagSCMHeadCategory .DEFAULT ;
@@ -173,12 +200,11 @@ public SCMHead getTarget() {
173200 assertThat (t .isMatch (mh , Arrays .asList (u , c , t )), is (false ));
174201 assertThat (t .isMatch (ch , Arrays .asList (c , u , t )), is (false ));
175202 assertThat (t .isMatch (th , Arrays .asList (c , u , t )), is (true ));
176-
177203 }
178204
179205 private static class MySCMCategory extends SCMCategory <Object > {
180206
181- private NonLocalizable defaultDisplayName ;
207+ private final NonLocalizable defaultDisplayName ;
182208
183209 public MySCMCategory (String name , NonLocalizable displayName , NonLocalizable defaultDisplayName ) {
184210 super (name , displayName );
0 commit comments