コード例 #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
ファイル: UserController.java プロジェクト: fabrodev/tatami
  /** 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());
 }