Search in sources :

Example 1 with FollowPayload

use of com.meisolsson.githubsdk.model.payload.FollowPayload in project PocketHub by pockethub.

the class NewsEventTextTest method testFollow.

/**
     * Verify text of follow event
     */
@UiThreadTest
public void testFollow() {
    User target = User.builder().login("user2").build();
    FollowPayload payload = FollowPayload.builder().target(target).build();
    GitHubEvent event = createEvent(GitHubEventType.FollowEvent, payload);
    updateView(event);
    verify("user started following user2");
}
Also used : User(com.meisolsson.githubsdk.model.User) FollowPayload(com.meisolsson.githubsdk.model.payload.FollowPayload) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) UiThreadTest(android.test.UiThreadTest)

Example 2 with FollowPayload

use of com.meisolsson.githubsdk.model.payload.FollowPayload in project PocketHub by pockethub.

the class UserEventMatcher method getUsers.

/**
     * Get {@link UserPair} from event
     *
     * @param event
     * @return user or null if event doesn't apply
     */
public UserPair getUsers(final GitHubEvent event) {
    if (event == null || event.payload() == null) {
        return null;
    }
    GitHubEventType type = event.type();
    if (GitHubEventType.FollowEvent.equals(type)) {
        User from = event.actor();
        User to = ((FollowPayload) event.payload()).target();
        if (from != null && to != null) {
            return new UserPair(from, to);
        }
    }
    return null;
}
Also used : User(com.meisolsson.githubsdk.model.User) FollowPayload(com.meisolsson.githubsdk.model.payload.FollowPayload) GitHubEventType(com.meisolsson.githubsdk.model.GitHubEventType)

Aggregations

User (com.meisolsson.githubsdk.model.User)2 FollowPayload (com.meisolsson.githubsdk.model.payload.FollowPayload)2 UiThreadTest (android.test.UiThreadTest)1 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)1 GitHubEventType (com.meisolsson.githubsdk.model.GitHubEventType)1