use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class IssueStoreTest method testReuseIssue.
/**
* Verify issue is updated when re-added
*/
@Test
public void testReuseIssue() {
IssueStore store = new IssueStore();
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();
assertNotEquals(issue, store.addIssue(issue2));
assertNotEquals(issue2.body(), issue.body());
assertNotEquals(issue, store.getIssue(repo, 1));
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class RepositoryUriMatcherTest method testHttpUriWithOwnerAndName.
/**
* Verify URI with owner but no name
*/
@Test
public void testHttpUriWithOwnerAndName() {
Repository repo = RepositoryUriMatcher.getRepository(Uri.parse("http://github.com/defunkt/resque"));
assertNotNull(repo);
assertEquals("resque", repo.name());
assertNotNull(repo.owner());
assertEquals("defunkt", repo.owner().login());
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class AccountDataManager method getIssueFilters.
/**
* Get bookmarked issue filters
* <p/>
* This method may perform network I/O and should never be called on the
* UI-thread
*
* @return non-null but possibly empty collection of issue filters
*/
public List<IssueFilter> getIssueFilters() {
List<GetFilters> filters = dbCache.database.getIssue_filterQueries().getFilters().executeAsList();
List<IssueFilter> issueFilters = new ArrayList<>();
for (GetFilters f : filters) {
Users owner = dbCache.database.getOrganizationsQueries().selectUser(f.getOwnerId()).executeAsOne();
Repository.Builder builder = Repository.builder().id(f.getRepoId()).name(f.getName()).owner(User.builder().id(owner.getId()).login(owner.getLogin()).name(owner.getName()).avatarUrl(owner.getAvatarurl()).build()).isPrivate(f.getPrivate()).isFork(f.getFork()).description(f.getDescription()).forksCount(f.getForks()).watchersCount(f.getWatchers()).language(f.getLanguage()).hasIssues(f.getHasIssues()).mirrorUrl(f.getMirrorUrl()).permissions(Permissions.builder().admin(f.getPermissions_admin()).pull(f.getPermissions_pull()).push(f.getPermissions_push()).build());
if (f.getOrgId() != null) {
Users org = dbCache.database.getOrganizationsQueries().selectUser(f.getOrgId()).executeAsOne();
builder.organization(User.builder().id(org.getId()).login(org.getLogin()).name(org.getName()).avatarUrl(org.getAvatarurl()).build());
}
Repository repo = builder.build();
IssueFilter filter = new IssueFilter(repo, f.getId());
if (f.getLogin() != null) {
filter.setAssignee(User.builder().id(f.getId__()).name(f.getName_()).login(f.getLogin()).avatarUrl(f.getAvatarurl()).build());
}
if (f.getMilestone_id() != null) {
filter.setMilestone(Milestone.builder().id(f.getMilestone_id()).build());
}
filter.setDirection(f.getDirection());
filter.setOpen(f.getOpen());
filter.setSortType(f.getSort_type());
List<GetFilterLabels> filterLabels = dbCache.database.getIssue_filterQueries().getFilterLabels(filter.getId()).executeAsList();
for (GetFilterLabels filterLabel : filterLabels) {
filter.addLabel(Label.builder().name(filterLabel.getName()).color(filterLabel.getColor()).build());
}
issueFilters.add(filter);
}
return issueFilters;
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class AccountDataManager method addIssueFilter.
/**
* Add issue filter to store
* <p/>
* This method may perform file I/O and should never be called on the
* UI-thread
*
* @param filter
*/
public Single<IssueFilter> addIssueFilter(final IssueFilter filter) {
Repository repo = filter.getRepository();
dbCache.getDatabase().getRepositoriesQueries().replaceRepo(repo.id(), repo.name(), repo.organization() != null ? repo.organization().id() : null, repo.owner().id(), repo.isPrivate(), repo.isFork(), repo.description(), repo.forksCount(), repo.watchersCount(), repo.language(), repo.hasIssues(), repo.mirrorUrl(), repo.permissions().admin(), repo.permissions().pull(), repo.permissions().push());
for (Label label : filter.getLabels()) {
dbCache.database.getIssue_filterQueries().insertOrReplaceLabel(repo.id(), label.name(), label.color());
dbCache.database.getIssue_filterQueries().insertOrReplaceIssueFilterLabel(filter.getId(), repo.id(), label.name());
}
if (filter.getMilestone() != null) {
dbCache.database.getIssue_filterQueries().insertOrReplaceMilestone(repo.id(), filter.getMilestone().title(), filter.getMilestone().state(), filter.getMilestone().id(), filter.getMilestone().number().longValue());
}
if (filter.getAssignee() != null) {
dbCache.database.getOrganizationsQueries().replaceUser(filter.getAssignee().id(), filter.getAssignee().login(), filter.getAssignee().name(), filter.getAssignee().avatarUrl());
}
dbCache.database.getIssue_filterQueries().insertOrReplaceIssueFilter(filter.getId(), repo.id(), filter.getMilestone() != null ? filter.getMilestone().id() : null, filter.getAssignee() != null ? filter.getAssignee().id() : null, filter.isOpen(), filter.getDirection(), filter.getSortType());
return Single.just(filter);
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class IssueFragment method openPullRequestCommits.
private void openPullRequestCommits() {
if (IssueUtils.isPullRequest(issue)) {
PullRequest pullRequest = issue.pullRequest();
String base = pullRequest.base().sha();
String head = pullRequest.head().sha();
Repository repo = pullRequest.base().repo();
startActivity(CommitCompareViewActivity.createIntent(repo, base, head));
}
}
Aggregations