本文整理汇总了Java中com.atlassian.jira.rest.client.api.JiraRestClient类的典型用法代码示例。如果您正苦于以下问题:Java JiraRestClient类的具体用法?Java JiraRestClient怎么用?Java JiraRestClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JiraRestClient类属于com.atlassian.jira.rest.client.api包,在下文中一共展示了JiraRestClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWithUriAndUsernameConfigFailsBecauseOfMissingConsole
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Test
public void getWithUriAndUsernameConfigFailsBecauseOfMissingConsole() throws Exception {
when(mockConfig.getUri()).thenReturn(URI.create("https://jira.company.com:1234"));
when(mockConfig.getUsername()).thenReturn("johndoe");
when(mockConsole.readPassword(anyString())).thenReturn("monkey123".toCharArray());
JiraRestClient client = provider.get(mockConfig);
assertThat(client).isNotNull();
}
示例2: getWithUriAndPasswordConfigIsOk
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Test
public void getWithUriAndPasswordConfigIsOk() throws Exception {
when(mockConfig.getUri()).thenReturn(URI.create("https://jira.company.com:1234"));
when(mockConfig.getPassword()).thenReturn("monkey123");
JiraRestClient client = provider.get(mockConfig);
assertThat(client).isNotNull();
}
示例3: getWithFullConfigIsOk
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Test
public void getWithFullConfigIsOk() throws Exception {
when(mockConfig.getUri()).thenReturn(URI.create("https://jira.company.com:1234"));
when(mockConfig.getUsername()).thenReturn("johndoe");
when(mockConfig.getPassword()).thenReturn("monkey123");
JiraRestClient client = provider.get(mockConfig);
assertThat(client).isNotNull();
}
示例4: checkConnection
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Override
public boolean checkConnection(ExternalSystem details) {
validateExternalSystemDetails(details);
try (JiraRestClient restClient = getClient(details.getUrl(), details.getUsername(), details.getPassword())) {
return restClient.getProjectClient().getProject(details.getProject()).claim() != null;
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return false;
}
}
示例5: getTicket
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Override
@Cacheable(value = CacheConfiguration.EXTERNAL_SYSTEM_TICKET_CACHE, key = "#system.url + #system.project + #id")
public Optional<Ticket> getTicket(final String id, ExternalSystem system) {
try (JiraRestClient client = getClient(system.getUrl(), system.getUsername(),
simpleEncryptor.decrypt(system.getPassword()))) {
return getTicket(id, system, client);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Optional.empty();
}
}
示例6: getIssueTypes
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Override
public List<String> getIssueTypes(ExternalSystem system) {
try (JiraRestClient client = getClient(system.getUrl(), system.getUsername(),
simpleEncryptor.decrypt(system.getPassword()))) {
Project jiraProject = getProject(client, system);
return StreamSupport.stream(jiraProject.getIssueTypes().spliterator(), false)
.map(IssueType::getName).collect(Collectors.toList());
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Collections.emptyList();
}
}
示例7: get
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
JiraRestClient get(JiraConfiguration jiraConfig) {
URI uri = checkNotNull(jiraConfig.getUri(), "No JIRA URI provided");
AuthenticationHandler authHandler = getAuthHandler(jiraConfig);
AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
return factory.create(uri, authHandler);
}
示例8: getWithEmptyConfigThrowsNPE
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@Test(expected = NullPointerException.class)
public void getWithEmptyConfigThrowsNPE() throws Exception {
JiraRestClient client = provider.get(mockConfig);
assertThat(client).isNotNull();
}
示例9: findIssue
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
private SearchResult findIssue(String id, JiraRestClient jiraRestClient) {
return jiraRestClient.getSearchClient().searchJql("issue = " + id).claim();
}
示例10: getClient
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
public JiraRestClient getClient(String uri, String providedUsername, String providePassword) {
return new AsynchronousJiraRestClientFactory()
.create(URI.create(uri), new BasicHttpAuthenticationHandler(providedUsername, providePassword));
}
示例11: fetchIssues
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
private Collection<Issue> fetchIssues(IssueTracker issueTracker) throws IOException {
Collection<Issue> issues = new HashSet<Issue>();
JiraURLParser.ParseResult parseResult = new JiraURLParser().parse(issueTracker.getUri());
final JiraRestClient restClient = factory.create(parseResult.getBaseURI(),
new AnonymousAuthenticationHandler());
final String jqlSearchString = "project=" + parseResult.getProjectKey();
int exceptionsOccurred = 0;
Promise<SearchResult> issuePromise = null;
int sizeBefore;
do {
if (exceptionsOccurred > 0) {
logger.debug("Restarted after " + exceptionsOccurred + " exceptions");
}
sizeBefore = issues.size();
try {
issuePromise = restClient.getSearchClient().searchJql(jqlSearchString,
numberOfIssuesFetchedAtOnce, issues.size(), null);
logger.debug("About to fetch issues");
Iterables.addAll(issues, issuePromise.claim().getIssues());
logger.debug("Sucessfully fetched " + issues.size() + " issues in total");
} catch (Exception e) {
if (exceptionsOccurred > maximumNumberOfExceptionsBeforeTermination) {
logger.debug("Exception occurred multiple times");
throw e;
} else {
logger.debug("Exception occurred for the " + (exceptionsOccurred + 1) + " time");
exceptionsOccurred++;
continue;
}
}
exceptionsOccurred = 0;
} while (issues.size() > sizeBefore || exceptionsOccurred > 0);
restClient.close();
return issues;
}
示例12: testFetch
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
@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>()); // TODO
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()));
}
示例13: extractGeneralMeasures
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
/**
* @param correctExecution
* @param restClient
* @param searchClient
* @param stats
* @return
*/
private void extractGeneralMeasures(JiraRestClient restClient, SearchRestClient searchClient, JiraLogStatistics stats) {
// double numberOfClosedFeatureRequestsPerUpdate;
// double numberOfClosedBugsPerUpdate;
String jql;
SearchResult results;
// Number of Versions
ProjectRestClient projectClient = restClient.getProjectClient();
Project project;
int countOfVersions = 0;
Iterable<BasicProject> basicProjects = projectClient.getAllProjects().claim();
for (BasicProject basicP : basicProjects) {
project = projectClient.getProject(basicP.getKey()).claim();
for (Version ver : project.getVersions()) {
countOfVersions++;
}
}
jql = "issuetype = Bug AND status in (Closed, Resolved)";
results = searchClient.searchJql(jql).claim();
stats.numberOfClosedBugsPerUpdate = (double) results.getTotal() / (double) countOfVersions;
jql = "issuetype = \"New Feature\" AND status in (Closed, Resolved)";
results = searchClient.searchJql(jql).claim();
stats.numberOfClosedFeatureRequestsPerUpdate = (double) results.getTotal() / (double) countOfVersions;
// stats.openBugs = numberOfOpenBugs;
stats.timeToResolveABug = stats.totalBugFixTime / stats.counterCloseBugs;
stats.timeToResolveABlockingOrCriticalBug = stats.totalCriticalBugFixTime / stats.counterCriticalBugs;
stats.numberOfFeatureRequests = stats.numberOfFeatureRequests;
stats.numberOfOpenFeatureRequests = stats.numberOfOpenFeatureRequests;
stats.numberOfSecurityBugs = (int) (stats.totalBugs * security_factor);
if (stats.counterCloseBugs > 0) { //TODO: check why this should express security bugs!
stats.presenceOfBugsCorrected = true; //TODO: check: was presenceOfSecurityBugsCorrected before!??
}
if (stats.counterSecurityBugs > 0) {
stats.timeToResolveASecurityBug = stats.totalSecurityBugFixTime / stats.counterSecurityBugs;
}
// return stats;
}
示例14: initializeRestClient
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
void initializeRestClient(final JiraRestClient restClient) throws Exception {
Validate.notNull(restClient, "Jira REST client must be specified.");
this.restClient = restClient;
jiraBuildNumber = this.restClient.getMetadataClient().getServerInfo().claim().getBuildNumber();
}
示例15: extractGeneralMeasures
import com.atlassian.jira.rest.client.api.JiraRestClient; //导入依赖的package包/类
/**
* @param restClient
* @param searchClient
* @param stats
* @return
*/
private void extractGeneralMeasures(JiraRestClient restClient, SearchRestClient searchClient,
JiraLogStatistics stats)
{
// double numberOfClosedFeatureRequestsPerUpdate;
// double numberOfClosedBugsPerUpdate;
String jql;
SearchResult results;
// Number of Versions
ProjectRestClient projectClient = restClient.getProjectClient();
Project project;
int countOfVersions = 0;
// int totalBugs = 0;
// int numberOfOpenBugs = 0;
// double totalCriticalBugFixTime = 0;
// int counterCriticalBugs = 0;
// double totalBugFixTime = 0;
// double totalSecurityBugFixTime = 0;
// int counterSecurityBugs = 0;
// int counterCloseBugs = 0;
// int numberOfFeatureRequests = 0;
// int numberOfOpenFeatureRequests = 0;
// boolean presenceOfSecurityBugsCorrected = false;
Iterable<BasicProject> basicProjects = projectClient.getAllProjects().claim();
for (BasicProject basicP : basicProjects) {
project = projectClient.getProject(basicP.getKey()).claim();
for (Version ver : project.getVersions()) {
countOfVersions++;
}
}
jql = "issuetype = Bug AND status in (Closed, Resolved)";
results = searchClient.searchJql(jql).claim();
stats.numberOfClosedBugsPerUpdate = (double) results.getTotal() / (double) countOfVersions;
jql = "issuetype = \"New Feature\" AND status in (Closed, Resolved)";
results = searchClient.searchJql(jql).claim();
stats.numberOfClosedFeatureRequestsPerUpdate = (double) results.getTotal() / (double) countOfVersions;
// stats.openBugs = numberOfOpenBugs;
stats.timeToResolveABug = stats.totalBugFixTime / stats.counterCloseBugs;
stats.timeToResolveABlockingOrCriticalBug = stats.totalCriticalBugFixTime / stats.counterCriticalBugs;
stats.numberOfFeatureRequests = stats.numberOfFeatureRequests;
stats.numberOfOpenFeatureRequests = stats.numberOfOpenFeatureRequests;
stats.numberOfSecurityBugs = (int) (stats.totalBugs * security_factor);
if (stats.counterCloseBugs > 0) { //TODO: check why this should express security bugs!
stats.presenceOfBugsCorrected = true; //TODO: check: was presenceOfSecurityBugsCorrected before!??
}
if (stats.counterSecurityBugs > 0) {
stats.timeToResolveASecurityBug = stats.totalSecurityBugFixTime / stats.counterSecurityBugs;
}
// return stats;
}