use of com.atlassian.jira.rest.client.api.SearchRestClient in project camel-spring-boot by apache.
the class NewCommentsConsumerTest method contextConfiguration.
@Bean
CamelContextConfiguration contextConfiguration() {
return new CamelContextConfiguration() {
@Override
public void beforeApplicationStart(CamelContext context) {
// get chance to mock camelContext/Registry
jiraRestClientFactory = mock(JiraRestClientFactory.class);
jiraClient = mock(JiraRestClient.class);
issueRestClient = mock(IssueRestClient.class);
searchRestClient = mock(SearchRestClient.class);
SearchResult result = new SearchResult(0, 50, 100, issues);
Promise<SearchResult> promiseSearchResult = Promises.promise(result);
Issue issue = createIssueWithComments(4L, 1);
Promise<Issue> promiseIssue = Promises.promise(issue);
when(jiraClient.getSearchClient()).thenReturn(searchRestClient);
when(jiraClient.getIssueClient()).thenReturn(issueRestClient);
when(jiraRestClientFactory.createWithBasicHttpAuthentication(any(), any(), any())).thenReturn(jiraClient);
when(searchRestClient.searchJql(any(), any(), any(), any())).thenReturn(promiseSearchResult);
when(issueRestClient.getIssue(anyString())).thenReturn(promiseIssue);
camelContext.getRegistry().bind(JIRA_REST_CLIENT_FACTORY, jiraRestClientFactory);
}
@Override
public void afterApplicationStart(CamelContext camelContext) {
// do nothing here
}
};
}
use of com.atlassian.jira.rest.client.api.SearchRestClient in project camel-spring-boot by apache.
the class NewIssuesConsumerTest method contextConfiguration.
@Bean
CamelContextConfiguration contextConfiguration() {
return new CamelContextConfiguration() {
@Override
public void beforeApplicationStart(CamelContext context) {
// get chance to mock camelContext/Registry
jiraRestClientFactory = mock(JiraRestClientFactory.class);
jiraClient = mock(JiraRestClient.class);
issueRestClient = mock(IssueRestClient.class);
searchRestClient = mock(SearchRestClient.class);
SearchResult result = new SearchResult(0, 50, 100, issues);
Promise<SearchResult> promiseSearchResult = Promises.promise(result);
when(jiraClient.getSearchClient()).thenReturn(searchRestClient);
when(jiraRestClientFactory.createWithBasicHttpAuthentication(any(), any(), any())).thenReturn(jiraClient);
when(searchRestClient.searchJql(any(), any(), any(), any())).thenReturn(promiseSearchResult);
camelContext.getRegistry().bind(JIRA_REST_CLIENT_FACTORY, jiraRestClientFactory);
}
@Override
public void afterApplicationStart(CamelContext camelContext) {
// do nothing here
}
};
}
use of com.atlassian.jira.rest.client.api.SearchRestClient in project seleniumRobot by bhecquet.
the class JiraConnector method issueAlreadyExists.
/**
* Check if issue already exists, and if so, returns an updated IssueBean
* @param issueBean a JiraBean instance
*
* @return
*/
@Override
public IssueBean issueAlreadyExists(IssueBean issueBean) {
if (!(issueBean instanceof JiraBean)) {
throw new ClassCastException("JiraConnector needs JiraBean instances");
}
JiraBean jiraBean = (JiraBean) issueBean;
String jql = String.format("project=%s and summary ~ \"%s\" and status in (\"%s\")", projectKey, jiraBean.getSummary().replace("[", "\\\\[").replace("]", "\\\\]"), StringUtils.join(openStates, "\",\""));
SearchRestClient searchClient = restClient.getSearchClient();
List<Issue> issues = ImmutableList.copyOf(searchClient.searchJql(jql).claim().getIssues());
if (!issues.isEmpty()) {
Issue issue = issues.get(0);
JiraBean updatedJiraBean = new JiraBean(issue.getKey(), jiraBean.getSummary(), issue.getDescription(), jiraBean.getPriority(), jiraBean.getIssueType(), jiraBean.getTestName(), jiraBean.getTestStep(), jiraBean.getAssignee(), jiraBean.getReporter(), jiraBean.getScreenShots(), jiraBean.getDetailedResult(), jiraBean.getCustomFields(), jiraBean.getComponents());
updatedJiraBean.setDate(issue.getCreationDate().toString("yyyy-MM-dd'T'HH:mmZZ"));
updatedJiraBean.setAccessUrl(browseUrl + issue.getKey());
return updatedJiraBean;
} else {
return null;
}
}
use of com.atlassian.jira.rest.client.api.SearchRestClient in project domui by fjalvingh.
the class JiraReporter method updateIssueByHash.
private boolean updateIssueByHash(JiraRestClient client, BugItem item, String hash) {
String hashField = getHashCodeFieldname();
if (null == hashField)
return false;
// see https://community.atlassian.com/t5/Jira-questions/Jira-Text-Search-in-Custom-Fields/qaq-p/26757
SearchRestClient searchClient = client.getSearchClient();
StringBuilder sb = new StringBuilder();
sb.append("project=\"").append(getProjectKey(item)).append("\"");
sb.append(" and ").append("cf[").append(hashField).append("]").append("~\"").append(hash).append("\"");
SearchResult result = searchClient.searchJql(sb.toString()).claim();
int total = result.getTotal();
if (0 == total) {
System.err.println("jira: no result for hash=" + hash);
return false;
}
for (Issue issue : result.getIssues()) {
String key = issue.getKey();
System.err.println("jira: key=" + key);
Comment comment = Comment.valueOf(calculateDescription(item));
client.getIssueClient().addComment(issue.getCommentsUri(), comment).claim();
System.err.println("jira: issue " + key + " updated");
return true;
}
return false;
}
use of com.atlassian.jira.rest.client.api.SearchRestClient in project camel-spring-boot by apache.
the class WatchUpdatesConsumerTest method contextConfiguration.
@Bean
CamelContextConfiguration contextConfiguration() {
return new CamelContextConfiguration() {
@Override
public void beforeApplicationStart(CamelContext context) {
// get chance to mock camelContext/Registry
jiraRestClientFactory = mock(JiraRestClientFactory.class);
jiraClient = mock(JiraRestClient.class);
issueRestClient = mock(IssueRestClient.class);
searchRestClient = mock(SearchRestClient.class);
SearchResult result = new SearchResult(0, 50, 100, issues);
Promise<SearchResult> promiseSearchResult = Promises.promise(result);
when(jiraClient.getSearchClient()).thenReturn(searchRestClient);
when(jiraRestClientFactory.createWithBasicHttpAuthentication(any(), any(), any())).thenReturn(jiraClient);
when(searchRestClient.searchJql(any(), any(), any(), any())).thenReturn(promiseSearchResult);
camelContext.getRegistry().bind(JIRA_REST_CLIENT_FACTORY, jiraRestClientFactory);
}
@Override
public void afterApplicationStart(CamelContext camelContext) {
// do nothing here
}
};
}
Aggregations