11package hudson .plugins .im ;
22
3- import com .google .common .base .Function ;
43import com .google .common .collect .Iterables ;
54import com .google .common .collect .Iterators ;
65import com .google .common .collect .Maps ;
1413import hudson .model .User ;
1514import hudson .plugins .im .build_notify .DefaultBuildToChatNotifier ;
1615import hudson .scm .ChangeLogSet ;
17- import hudson .scm .NullSCM ;
1816import hudson .tasks .BuildStepDescriptor ;
1917import hudson .tasks .Publisher ;
18+ import org .junit .jupiter .api .BeforeEach ;
2019
21- import java .io .IOException ;
2220import java .util .Collection ;
2321import java .util .Collections ;
2422import java .util .Iterator ;
2523import java .util .Map ;
2624import java .util .Set ;
2725
28- import org .junit .Before ;
29- import org .junit .Test ;
30-
31- import static org .junit .Assert .assertEquals ;
32- import static org .junit .Assert .assertFalse ;
33- import static org .junit .Assert .assertTrue ;
26+ import org .junit .jupiter .api .Test ;
3427
28+ import static org .junit .jupiter .api .Assertions .*;
3529import static org .mockito .Mockito .mock ;
3630import static org .mockito .Mockito .when ;
3731
3832@ SuppressWarnings ("rawtypes" )
39- public class IMPublisherTest {
33+ class IMPublisherTest {
4034
4135 private IMPublisher imPublisher ;
4236
@@ -53,10 +47,10 @@ public class IMPublisherTest {
5347 private BuildListener listener ;
5448 private RangeSet rangeset ;
5549
56- @ SuppressWarnings ("unchecked" )
57- @ Before
5850 // lot of ugly mocking going on here ...
59- public void before () throws IOException {
51+ @ SuppressWarnings ("unchecked" )
52+ @ BeforeEach
53+ void setUp () {
6054
6155 this .imPublisher = new IMTestPublisher ();
6256
@@ -140,18 +134,13 @@ private static void createPreviousNextRelationShip(AbstractBuild... builds) {
140134 * list.
141135 */
142136 @ Test
143- public void testIncludeUpstreamCulprits () throws Exception {
137+ void testIncludeUpstreamCulprits () {
144138 /* Anticipating javax.mail.MessagingException and InterruptedException */
145139 Set <User > recipients = this .imPublisher .getNearestUpstreamCommitters (this .build , listener ).keySet ();
146140
147- assertEquals (recipients .toString (), 2 , recipients .size ());
141+ assertEquals (2 , recipients .size (), recipients .toString ());
148142
149- Iterable <String > userNamesIter = Iterables .transform (recipients , new Function <User , String >() {
150- @ Override
151- public String apply (User from ) {
152- return from .toString ();
153- }
154- });
143+ Iterable <String > userNamesIter = Iterables .transform (recipients , User ::toString );
155144
156145 Set <String > userNames = Sets .newHashSet (userNamesIter );
157146
@@ -162,7 +151,7 @@ public String apply(User from) {
162151
163152 private static class IMTestPublisher extends IMPublisher {
164153 public IMTestPublisher () {
165- super (Collections .< IMMessageTarget > emptyList (), NotificationStrategy .FAILURE_AND_FIXED .getDisplayName (),
154+ super (Collections .emptyList (), NotificationStrategy .FAILURE_AND_FIXED .getDisplayName (),
166155 true , true , true , true , true , new DefaultBuildToChatNotifier (), MatrixJobMultiplier .ALL );
167156 }
168157
@@ -172,7 +161,7 @@ protected String getPluginName() {
172161 }
173162
174163 @ Override
175- protected IMConnection getIMConnection () throws IMException {
164+ protected IMConnection getIMConnection () {
176165 return null ;
177166 }
178167
0 commit comments