@Test(expected = NullPointerException.class)
  public void testBuild() throws Exception {
    Long followingVkId = 1L;
    String accessToken = "accessToken";
    when(following.getUserInfo()).thenReturn(userInfo);
    when(userInfo.getVkId()).thenReturn(followingVkId);
    when(follower.getAccessToken()).thenReturn(accessToken);
    when(apiService.requestPosts(followingVkId, 0L, accessToken)).thenReturn(null);

    postSnapshotBuilder.build(following, follower);
  }
Exemplo n.º 2
0
  private void refreshFollowing(Follower follower, Following following) {
    FollowingEventTypes followingEventTypes =
        follower
            .getFollowing_EventTypesList()
            .stream()
            .filter(following_eventTypes -> following_eventTypes.getFollowing() == following)
            .findFirst()
            .get();
    List<EventType> eventTypes = followingEventTypes.getEventTypes();

    FollowerEvents followerEvents =
        following
            .getFollower_EventsList()
            .stream()
            .filter(follower_events -> follower_events.getFollower() == follower)
            .findFirst()
            .get();
    List<Snapshot> snapshots = followerEvents.getSnapshots();

    for (int i = 0; i < eventTypes.size(); i++) {
      EventType eventType = eventTypes.get(i);
      switch (eventType) {
        case AUDIO:
          Process(
              audioSnapshotBuilder,
              follower,
              following,
              followingEventTypes,
              followerEvents,
              snapshots,
              i,
              Audio.class,
              AudioListSnapshot.class,
              AudioEvent.class,
              new AudioSnapshotDifference(),
              EventType.AUDIO);
          break;
        case VIDEO:
          Process(
              videoSnapshotBuilder,
              follower,
              following,
              followingEventTypes,
              followerEvents,
              snapshots,
              i,
              Video.class,
              VideoListSnapshot.class,
              VideoEvent.class,
              new VideoSnapshotDifference(),
              EventType.VIDEO);
          break;
        case FRIEND:
          Process(
              friendSnapshotBuilder,
              follower,
              following,
              followingEventTypes,
              followerEvents,
              snapshots,
              i,
              Friend.class,
              FriendListSnapshot.class,
              FriendEvent.class,
              new FriendSnapshotDifference(),
              EventType.FRIEND);
          break;
        case GROUP:
          Process(
              groupSnapshotBuilder,
              follower,
              following,
              followingEventTypes,
              followerEvents,
              snapshots,
              i,
              Group.class,
              GroupListSnapshot.class,
              GroupEvent.class,
              new GroupSnapshotDifference(),
              EventType.GROUP);
          break;
        case POST:
          Process(
              postSnapshotBuilder,
              follower,
              following,
              followingEventTypes,
              followerEvents,
              snapshots,
              i,
              Post.class,
              PostListSnapshot.class,
              PostEvent.class,
              new PostSnapshotDifference(),
              EventType.POST);
      }
    }
  }