Search in sources :

Example 6 with Issue

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;
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue)

Example 7 with 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));
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Issue(com.meisolsson.githubsdk.model.Issue) IssueStore(com.github.pockethub.android.core.issue.IssueStore)

Example 8 with Issue

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());
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue)

Example 9 with Issue

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());
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue)

Example 10 with Issue

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;
        }
    };
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) SearchService(com.meisolsson.githubsdk.service.search.SearchService) ArrayList(java.util.ArrayList) ThrowableLoader(com.github.pockethub.android.ThrowableLoader)

Aggregations

Issue (com.meisolsson.githubsdk.model.Issue)24 Repository (com.meisolsson.githubsdk.model.Repository)6 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)3 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 UiThreadTest (android.test.UiThreadTest)2 Builder (com.github.pockethub.android.Intents.Builder)2 FullIssue (com.github.pockethub.android.core.issue.FullIssue)2 ProgressObserverAdapter (com.github.pockethub.android.rx.ProgressObserverAdapter)2 GitHubComment (com.meisolsson.githubsdk.model.GitHubComment)2 User (com.meisolsson.githubsdk.model.User)2 IssueCommentPayload (com.meisolsson.githubsdk.model.payload.IssueCommentPayload)2 IssuesPayload (com.meisolsson.githubsdk.model.payload.IssuesPayload)2 IssueRequest (com.meisolsson.githubsdk.model.request.issue.IssueRequest)2 ActionBar (android.support.v7.app.ActionBar)1 ThrowableLoader (com.github.pockethub.android.ThrowableLoader)1 IssueFilter (com.github.pockethub.android.core.issue.IssueFilter)1 IssueStore (com.github.pockethub.android.core.issue.IssueStore)1 UserPair (com.github.pockethub.android.core.user.UserEventMatcher.UserPair)1