JiraIssueTrackerStrategy implements IssueTrackerStrategy { @Override public Collection<Bug> fetch(IssueTracker issueTracker) throws IOException { Collection<Issue> issues = fetchIssues(issueTracker); Collection<Bug> fetchedBugs = createBugs(issueTracker, issues); return fetchedBugs; } protected  JiraIssueTrackerStrategy(); @Override Collection<Bug> fetch(IssueTracker issueTracker); int getNumberOfIssuesFetchedAtOnce(); void setNumberOfIssuesFetchedAtOnce(int numberOfIssuesFetchedAtOnce); int getMaximumNumberOfExceptionsBeforeTermination(); void setMaximumNumberOfExceptionsBeforeTermination(int maximumNumberOfExceptionsBeforeTermination);  }
@Test public void testFetch() throws IOException { JiraRestClient client = mock(JiraRestClient.class); SearchRestClient searchClient = mock(SearchRestClient.class); SearchResult searchResult = mock(SearchResult.class); when(factory.create(eq(URI.create(API_URL)), org.mockito.Matchers.isA(AnonymousAuthenticationHandler.class))) .thenReturn(client); when(client.getSearchClient()).thenReturn(searchClient); when(searchClient.searchJql(eq("project=" + issueTracker.getProject().getName()), org.mockito.Matchers.isA(Integer.class), org.mockito.Matchers.isA(Integer.class), anySetOf(String.class))).thenReturn(promise); when(promise.claim()).thenReturn(searchResult); when(searchResult.getIssues()).thenReturn(issues).thenReturn(new HashSet<Issue>()); IssueType type = mock(IssueType.class); when(issue1.getIssueType()).thenReturn(type); when(type.getName()).thenReturn("Bug"); Status status = mock(Status.class); when(issue1.getStatus()).thenReturn(status); when(status.getName()).thenReturn("Closed"); when(issue1.getSummary()).thenReturn("Bug #1337"); IssueField resolutionDate = mock(IssueField.class); when(issue1.getField(eq("resolutiondate"))).thenReturn(resolutionDate); when(resolutionDate.getValue()).thenReturn(BUG_RESOLUTION_DATE); when(issue1.getCreationDate()).thenReturn(BUG_REPORT_TIME); when(issue1.getLabels()).thenReturn(new HashSet<String>()); when(issue1.getDescription()).thenReturn(BUG_DESCRIPTION); Resolution resolution = mock(Resolution.class); when(issue1.getResolution()).thenReturn(resolution); when(resolution.getName()).thenReturn("Done"); Collection<Bug> result = strategy.fetch(issueTracker); assertThat(result.size(), is(1)); Bug bug = result.iterator().next(); assertThat(bug.getTitle(), is("Bug #1337")); assertThat(bug.getReportTime(), is(Instant.ofEpochMilli(BUG_REPORT_TIME.getMillis()))); assertThat(bug.isFixed(), is(true)); assertThat(bug.getDescription(), is(BUG_DESCRIPTION)); assertThat(bug.getProject().getName(), is(issueTracker.getProject().getName())); assertThat(bug.getIssueTracker().getUri(), is(issueTracker.getUri())); }