TimelineService { public Collection<StatusDTO> getUserline(String username, int nbStatus, String start, String finish) { String login; User currentUser = authenticationService.getCurrentUser(); if (username == null || username.isEmpty()) { login = currentUser.getLogin(); } else { String domain = DomainUtil.getDomainFromLogin(currentUser.getLogin()); login = DomainUtil.getLoginFromUsernameAndDomain(username, domain); } List<String> statuses = userlineRepository.getUserline(login, nbStatus, start, finish); Collection<StatusDTO> dtos = buildStatusList(statuses); if (statuses.size() != dtos.size()) { Collection<String> statusIdsToDelete = findStatusesToCleanUp(statuses, dtos); userlineRepository.removeStatusesFromUserline(login, statusIdsToDelete); return getUserline(username, nbStatus, start, finish); } dtos = filterStatusFromBlockedUsers(dtos); return dtos; }  StatusDTO getStatus(String statusId); StatusDetails getStatusDetails(String statusId); Collection<StatusDTO> buildStatusList(List<String> line); Collection<StatusDTO> getMentionline(int nbStatus, String start, String finish); Collection<StatusDTO> getTagline(String tag, int nbStatus, String start, String finish); Collection<StatusDTO> getGroupline(String groupId, Integer nbStatus, String start, String finish); Collection<StatusDTO> getTimeline(int nbStatus, String start, String finish); Collection<StatusDTO> getUserTimeline(String login, int nbStatus, String start, String finish); Collection<StatusDTO> getDomainline(int nbStatus, String start, String finish); Collection<StatusDTO> getUserline(String username, int nbStatus, String start, String finish); void removeStatus(String statusId); void shareStatus(String statusId); void addFavoriteStatus(String statusId); void removeFavoriteStatus(String statusId); void announceStatus(String statusId); Collection<StatusDTO> getFavoritesline(); void hideStatus(String statusId);  }
@Test public void shouldGetUserline() throws Exception { String username = "userWithStatus"; String login = "userWithStatus@ippon.fr"; mockAuthenticationOnTimelineServiceWithACurrentUser(login); Collection<StatusDTO> status = timelineService.getUserline(username, 10, null, null); assertThatLineForUserWithStatusIsOk(username, status); }
@Test public void shouldGetAuthenticateUserUserlineWithNullLoginSet() throws Exception { String login = "userWithStatus@ippon.fr"; mockAuthenticationOnTimelineServiceWithACurrentUser("userWithStatus@ippon.fr"); Collection<StatusDTO> status = timelineService.getUserline(null, 10, null, null); assertThatLineForUserWithStatusIsOk("userWithStatus", status); }
@Test public void shouldGetAuthenticateUserUserlineWithEmptyLoginSet() throws Exception { String username = "userWithStatus"; mockAuthenticationOnTimelineServiceWithACurrentUser("userWithStatus@ippon.fr"); Collection<StatusDTO> status = timelineService.getUserline("", 10, null, null); assertThatLineForUserWithStatusIsOk(username, status); }