use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_gollum_then_icon_should_be_gollum_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_gollum_then_icon_should_be_gollum_and_its_text_should_be_formatted() throws Exception {
// Arrange
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.GollumEvent).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatWiki(event, null, null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, null, null);
// Assert
assertEquals(TypefaceUtils.ICON_WIKI, icon);
verify(spyIconAndViewTextManager).formatWiki(event, null, null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_issues_and_action_is_opened_then_icon_should_be_issue_open_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_issues_and_action_is_opened_then_icon_should_be_issue_open_and_its_text_should_be_formatted() throws Exception {
// Arrange
IssuesPayload payload = IssuesPayload.builder().action(IconAndViewTextManager.ISSUES_PAYLOAD_ACTION_OPENED).build();
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.IssuesEvent).payload(payload).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatIssues(event, null, null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, null, null);
// Assert
assertEquals(TypefaceUtils.ICON_ISSUE_OPEN, icon);
verify(spyIconAndViewTextManager).formatIssues(event, null, null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_delete_then_icon_should_be_delete_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_delete_then_icon_should_be_delete_and_its_text_should_be_formatted() throws Exception {
// Arrange
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.DeleteEvent).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatDelete(event, null, null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, null, null);
// Assert
assertEquals(TypefaceUtils.ICON_DELETE, icon);
verify(spyIconAndViewTextManager).formatDelete(event, null, null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_member_then_icon_should_be_add_member_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_member_then_icon_should_be_add_member_and_its_text_should_be_formatted() throws Exception {
// Arrange
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.MemberEvent).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatAddMember(event, null, null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, null, null);
// Assert
assertEquals(TypefaceUtils.ICON_ADD_MEMBER, icon);
verify(spyIconAndViewTextManager).formatAddMember(event, null, null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class NewsFragment method onItemClick.
@Override
public void onItemClick(@NonNull Item item, @NonNull View view) {
if (!(item instanceof NewsItem)) {
return;
}
GitHubEvent event = ((NewsItem) item).getGitHubEvent();
if (DownloadEvent.equals(event.type())) {
openDownload(event);
return;
}
if (PushEvent.equals(event.type())) {
openPush(event);
return;
}
if (CommitCommentEvent.equals(event.type())) {
openCommitComment(event);
return;
}
Issue issue = IssueEventMatcher.getIssue(event);
if (issue != null) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
viewIssue(issue, repo);
return;
}
Gist gist = GistEventMatcher.getGist(event);
if (gist != null) {
startActivity(GistsViewActivity.createIntent(gist));
return;
}
Repository repo = RepositoryEventMatcher.getRepository(event);
if (repo != null) {
viewRepository(repo);
}
UserPair users = UserEventMatcher.getUsers(event);
if (users != null) {
viewUser(users);
}
}
Aggregations