use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class IssueStore method addIssue.
/**
* Add issue to store
*
* @param repository
* @param issue
* @return issue
*/
public Issue addIssue(Repository repository, Issue issue) {
Issue current = getIssue(repository, issue.number());
if (current != null && current.equals(issue)) {
return current;
}
String repoId = InfoUtils.createRepoId(repository);
ItemReferences<Issue> repoIssues = repos.get(repoId);
if (repoIssues == null) {
repoIssues = new ItemReferences<>();
repos.put(repoId, repoIssues);
}
repoIssues.put(issue.number(), issue);
return issue;
}
use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class IssueStoreTest method testReuseIssue.
/**
* Verify issue is updated when re-added
*/
public void testReuseIssue() {
IssueStore store = new IssueStore(mContext);
Repository repo = InfoUtils.createRepoFromData("owner", "name");
assertNull(store.getIssue(repo, 1));
Issue issue = Issue.builder().repository(repo).number(1).body("body").build();
assertEquals(issue, store.addIssue(issue));
assertEquals(issue, store.getIssue(repo, 1));
Issue issue2 = Issue.builder().repository(repo).number(1).body("body2").build();
assertNotEqual(issue, store.addIssue(issue2));
assertNotEqual(issue2.body(), issue.body());
assertNotEqual(issue, store.getIssue(repo, 1));
}
use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class IssueUriMatcherTest method testPullUri.
/**
* Verify pull uri
*/
public void testPullUri() {
Issue issue = IssueUriMatcher.getIssue(Uri.parse("https://github.com/defunkt/resque/pull/3"));
assertNotNull(issue);
assertEquals(3, issue.number().intValue());
assertNotNull(issue.repository());
assertEquals("resque", issue.repository().name());
assertNotNull(issue.repository().owner());
assertEquals("defunkt", issue.repository().owner().login());
}
use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class IssueUriMatcherTest method testHttpUri.
/**
* Verify http uri
*/
public void testHttpUri() {
Issue issue = IssueUriMatcher.getIssue(Uri.parse("https://github.com/defunkt/resque/issues/3"));
assertNotNull(issue);
assertEquals(3, issue.number().intValue());
assertNotNull(issue.repository());
assertEquals("resque", issue.repository().name());
assertNotNull(issue.repository().owner());
assertEquals("defunkt", issue.repository().owner().login());
}
use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class SearchIssueListFragment method onCreateLoader.
@Override
public Loader<List<Issue>> onCreateLoader(int id, Bundle args) {
return new ThrowableLoader<List<Issue>>(getActivity(), items) {
@Override
public List<Issue> loadData() throws Exception {
if (repository == null) {
return Collections.emptyList();
}
List<Issue> matches = new ArrayList<>();
SearchService service = ServiceGenerator.createService(getActivity(), SearchService.class);
int current = 1;
int last = 0;
while (current != last) {
SearchPage<Issue> page = service.searchIssues(query, null, null, current).blockingGet();
matches.addAll(page.items());
last = page.last() != null ? page.last() : -1;
current = page.next() != null ? page.next() : -1;
}
Collections.sort(matches, SearchIssueListFragment.this);
return matches;
}
};
}
Aggregations