Пример #1
0
 @Override
 public void onTweetRemove(Tweet tweet) throws FunctionalException {
   if (!tweet.isNotification()) {
     User currentUser = userService.getCurrentUser();
     this.userLineRepository.removeTweetFromUserline(currentUser, tweet.getTweetId());
   }
 }
Пример #2
0
  /** GET /users/suggestions -> suggest users to follow */
  @RequestMapping(
      value = "/rest/users/suggestions",
      method = RequestMethod.GET,
      produces = "application/json")
  @ResponseBody
  public Collection<User> suggestions() {
    User currentUser = userService.getCurrentUser();
    final String login = currentUser.getLogin();
    if (log.isDebugEnabled()) {
      log.debug("REST request to get the last active tweeters list (except " + login + ").");
    }

    Collection<String> exceptions = userService.getFriendsForUser(login);
    exceptions.add(login);

    Collection<Tweet> tweets = timelineService.getDayline("");
    Map<String, User> users = new HashMap<String, User>();
    for (Tweet tweet : tweets) {
      if (exceptions.contains(tweet.getLogin())) continue;

      users.put(tweet.getLogin(), userService.getUserProfileByLogin(tweet.getLogin()));
      if (users.size() == 3) break; // suggestions list limit
    }
    return users.values();
  }
Пример #3
0
  @Test(expected = ConstraintViolationException.class)
  public void shouldNotCreateATweetBecauseContentEmpty() {
    String login = "******";
    String content = "";

    Tweet tweet = new Tweet();
    tweet.setContent(content);
    tweet.setLogin(login);

    tweetRepository.createTweet(login, content);
  }
Пример #4
0
  @Test(expected = ValidationException.class)
  public void shouldNotCreateATweetBecauseLoginNull() {
    String login = null;
    String content = "content";

    Tweet tweet = new Tweet();
    tweet.setContent(content);
    tweet.setLogin(login);

    tweetRepository.createTweet(login, content);
  }
Пример #5
0
  @Test
  public void shouldCreateATweet() {
    String login = "******";
    String content = "content";

    Tweet tweet = new Tweet();
    tweet.setContent(content);
    tweet.setLogin(login);

    assertThat(tweetRepository.createTweet(login, content), notNullValue());
  }
Пример #6
0
 @Override
 public void onTweetPost(Tweet tweet) {
   User currentUser = userService.getCurrentUser();
   userLineRepository.addTweetToUserline(currentUser, tweet.getTweetId());
 }