11package org .csanchez .jenkins .plugins .kubernetes ;
22
3- import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert .assertNotNull ;
5- import static org .junit .Assert .assertNull ;
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
65import static org .mockito .Mockito .doReturn ;
76import static org .mockito .Mockito .when ;
87
98import io .fabric8 .kubernetes .api .model .Pod ;
109import io .fabric8 .kubernetes .api .model .PodSecurityContext ;
1110import java .util .Arrays ;
1211import org .csanchez .jenkins .plugins .kubernetes .pod .yaml .Overrides ;
13- import org .junit .Before ;
14- import org .junit .Rule ;
15- import org .junit .Test ;
12+ import org .junit .jupiter . api . BeforeEach ;
13+ import org .junit .jupiter . api . Test ;
14+ import org .junit .jupiter . api . extension . ExtendWith ;
1615import org .jvnet .hudson .test .JenkinsRule ;
16+ import org .jvnet .hudson .test .junit .jupiter .WithJenkins ;
1717import org .mockito .Mock ;
1818import org .mockito .Spy ;
19- import org .mockito .junit .MockitoJUnit ;
20- import org .mockito .junit .MockitoRule ;
19+ import org .mockito .junit .jupiter .MockitoExtension ;
2120
2221/**
2322 * Verifies supplementalGroups from pod template UI/CasC fields survive yaml override merge.
2423 * Related to jenkinsci/kubernetes-plugin#2444.
2524 */
26- public class SupplementalGroupsYamlOverrideReproTest {
25+ @ WithJenkins
26+ @ ExtendWith (MockitoExtension .class )
27+ class SupplementalGroupsYamlOverrideReproTest {
2728
2829 private static final String AGENT_NAME = "jenkins-agent" ;
2930 private static final String AGENT_SECRET = "xxx" ;
3031 private static final String JENKINS_URL = "http://jenkins.example.com" ;
3132
32- @ Rule
33- public JenkinsRule r = new JenkinsRule ();
34-
35- @ Rule
36- public MockitoRule mockitoRule = MockitoJUnit .rule ();
33+ private JenkinsRule r ;
3734
3835 @ Spy
3936 private KubernetesCloud cloud = new KubernetesCloud ("test" );
@@ -44,8 +41,9 @@ public class SupplementalGroupsYamlOverrideReproTest {
4441 @ Mock
4542 private KubernetesComputer computer ;
4643
47- @ Before
48- public void setUp () {
44+ @ BeforeEach
45+ void setUp (JenkinsRule rule ) {
46+ r = rule ;
4947 when (slave .getKubernetesCloud ()).thenReturn (cloud );
5048 doReturn (JENKINS_URL ).when (cloud ).getJenkinsUrlOrDie ();
5149 when (computer .getName ()).thenReturn (AGENT_NAME );
@@ -54,7 +52,7 @@ public void setUp() {
5452 }
5553
5654 @ Test
57- public void supplementalGroupsPresentWithoutRawYaml () throws Exception {
55+ void supplementalGroupsPresentWithoutRawYaml () throws Exception {
5856 PodTemplate template = baseTemplate ();
5957 Pod pod = new PodTemplateBuilder (template , slave ).build ();
6058
@@ -64,7 +62,7 @@ public void supplementalGroupsPresentWithoutRawYaml() throws Exception {
6462 }
6563
6664 @ Test
67- public void supplementalGroupsPreservedWhenRawYamlOverrideIsUsed () throws Exception {
65+ void supplementalGroupsPreservedWhenRawYamlOverrideIsUsed () throws Exception {
6866 PodTemplate template = baseTemplate ();
6967 template .setYamlMergeStrategy (new Overrides ());
7068 template .setYaml (
@@ -84,9 +82,9 @@ public void supplementalGroupsPreservedWhenRawYamlOverrideIsUsed() throws Except
8482 PodSecurityContext sc = pod .getSpec ().getSecurityContext ();
8583 assertNotNull (sc );
8684 assertEquals (
87- "expected supplementalGroups [5001, 5002] from pod template fields" ,
8885 Arrays .asList (5001L , 5002L ),
89- sc .getSupplementalGroups ());
86+ sc .getSupplementalGroups (),
87+ "expected supplementalGroups [5001, 5002] from pod template fields" );
9088 }
9189
9290 private static PodTemplate baseTemplate () {
0 commit comments