File tree Expand file tree Collapse file tree
src/test/java/org/jenkinsci/plugins/github/status/sources Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .jenkinsci .plugins .github .status .sources ;
22
3+ import hudson .model .FreeStyleProject ;
34import hudson .model .Run ;
45import hudson .model .TaskListener ;
56import org .junit .Rule ;
67import org .junit .Test ;
78import org .junit .runner .RunWith ;
9+ import org .jvnet .hudson .test .JenkinsRule ;
810import org .mockito .Answers ;
911import org .mockito .Mock ;
1012import org .mockito .junit .MockitoJUnit ;
2224public class BuildRefBackrefSourceTest {
2325
2426 @ Rule
25- public MockitoRule mockitoRule = MockitoJUnit .rule ();
26-
27- @ Mock (answer = Answers .RETURNS_MOCKS )
28- private Run run ;
27+ public JenkinsRule jenkinsRule = new JenkinsRule ();
2928
3029 @ Mock (answer = Answers .RETURNS_MOCKS )
3130 private TaskListener listener ;
3231
3332 @ Test
33+ /**
34+ * Should've used mocked Run, but getAbsoluteUrl is final.
35+ *
36+ * @throws Exception
37+ */
3438 public void shouldReturnRunAbsoluteUrl () throws Exception {
35- when ( run . getAbsoluteUrl ()). thenReturn ( "ABSOLUTE_URL" );
39+ Run <?, ?> run = jenkinsRule . buildAndAssertSuccess ( jenkinsRule . createFreeStyleProject () );
3640
3741 String result = new BuildRefBackrefSource ().get (run , listener );
38- assertThat ("state" , result , is ("ABSOLUTE_URL" ));
42+ assertThat ("state" , result , is (run . getAbsoluteUrl () ));
3943 }
4044
4145}
You can’t perform that action at this time.
0 commit comments