Java Code Examples for jenkins.scm.api.SCMHead#HeadByItem
The following examples show how to use
jenkins.scm.api.SCMHead#HeadByItem .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CachesTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void testPullRequestCacheLoader() throws Exception { ObjectMetadataAction metadataAction = new ObjectMetadataAction("A cool PR", "A very cool change", "http://example.com/pr/1"); when(job.getAction(ObjectMetadataAction.class)).thenReturn(metadataAction); ContributorMetadataAction contributorMetadataAction = new ContributorMetadataAction("Hates Cake", "He hates cake", "[email protected]"); when(job.getAction(ContributorMetadataAction.class)).thenReturn(contributorMetadataAction); PowerMockito.mockStatic(ExtensionList.class); ExtensionList<SCMHead.HeadByItem> extensionList = mock(ExtensionList.class); when(extensionList.iterator()).thenReturn(Lists.<SCMHead.HeadByItem>newArrayList(new HeadByItemForTest()).iterator()); when(ExtensionList.lookup(SCMHead.HeadByItem.class)).thenReturn(extensionList); Caches.PullRequestCacheLoader loader = new Caches.PullRequestCacheLoader(jenkins); BranchImpl.PullRequest pr = loader.load(job.getFullName()).orNull(); assertNotNull(pr); assertEquals("Hates Cake", pr.getAuthor()); assertEquals("1", pr.getId()); assertEquals("A cool PR", pr.getTitle()); assertEquals("http://example.com/pr/1", pr.getUrl()); }
Example 2
Source File: CachesTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void testPullRequestCacheLoaderWithoutScmHead() throws Exception { ObjectMetadataAction metadataAction = new ObjectMetadataAction("A cool PR", "A very cool change", "http://example.com/pr/1"); when(job.getAction(ObjectMetadataAction.class)).thenReturn(metadataAction); ContributorMetadataAction contributorMetadataAction = new ContributorMetadataAction("Hates Cake", "He hates cake", "[email protected]"); when(job.getAction(ContributorMetadataAction.class)).thenReturn(contributorMetadataAction); PowerMockito.mockStatic(ExtensionList.class); ExtensionList<SCMHead.HeadByItem> extensionList = mock(ExtensionList.class); when(extensionList.iterator()).thenReturn(Lists.<SCMHead.HeadByItem>newArrayList().iterator()); when(ExtensionList.lookup(SCMHead.HeadByItem.class)).thenReturn(extensionList); Caches.PullRequestCacheLoader loader = new Caches.PullRequestCacheLoader(jenkins); BranchImpl.PullRequest pr = loader.load(job.getFullName()).orNull(); assertNull(pr); }
Example 3
Source File: CachesTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void testPullRequestCacheLoaderWithoutObjectMetadataAction() throws Exception { ContributorMetadataAction contributorMetadataAction = new ContributorMetadataAction("Hates Cake", "He hates cake", "[email protected]"); when(job.getAction(ContributorMetadataAction.class)).thenReturn(contributorMetadataAction); PowerMockito.mockStatic(ExtensionList.class); ExtensionList<SCMHead.HeadByItem> extensionList = mock(ExtensionList.class); when(extensionList.iterator()).thenReturn(Lists.<SCMHead.HeadByItem>newArrayList(new HeadByItemForTest()).iterator()); when(ExtensionList.lookup(SCMHead.HeadByItem.class)).thenReturn(extensionList); Caches.PullRequestCacheLoader loader = new Caches.PullRequestCacheLoader(jenkins); BranchImpl.PullRequest pr = loader.load(job.getFullName()).orNull(); assertNotNull(pr); assertEquals("Hates Cake", pr.getAuthor()); assertEquals("1", pr.getId()); assertNull(pr.getTitle()); assertNull(pr.getUrl()); }