aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-07-18 08:34:49 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-07-18 08:34:49 +0200
commit774f1a5d879b22ddb6804da86785307717411f59 (patch)
treeba2a0a80abf68c9d4979e6592cb25ca9359a789a
parentf75f69b162e01c9822d966038df47e5ad103d7d4 (diff)
downloadsonarqube-774f1a5d879b22ddb6804da86785307717411f59.tar.gz
sonarqube-774f1a5d879b22ddb6804da86785307717411f59.zip
Revert "Fix issue when loading issues page without being logged"
This reverts commit f75f69b162e01c9822d966038df47e5ad103d7d4.
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java5
-rw-r--r--sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java26
2 files changed, 17 insertions, 14 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java b/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java
index 372f708df34..cff4e165ce9 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java
@@ -24,7 +24,6 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
-import edu.emory.mathcs.backport.java.util.Collections;
import org.sonar.api.ServerComponent;
import org.sonar.api.issue.IssueFinder;
import org.sonar.api.issue.IssueQuery;
@@ -44,6 +43,7 @@ import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
+
import java.util.List;
import java.util.Map;
@@ -163,9 +163,6 @@ public class IssueFilterService implements ServerComponent {
}
public List<DefaultIssueFilter> findFavoriteFilters(UserSession userSession) {
- if (!userSession.isLoggedIn()) {
- return Collections.emptyList();
- }
return toIssueFilters(filterDao.selectFavoriteFiltersByUser(getLoggedLogin(userSession)));
}
diff --git a/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java
index a124daac763..a2cc7bd783c 100644
--- a/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java
@@ -218,7 +218,7 @@ public class IssueFilterServiceTest {
@Test
public void should_not_save_shared_filter_if_name_already_used_by_shared_filter() {
- when(issueFilterDao.selectByUser(eq("john"))).thenReturn(Collections.<IssueFilterDto>emptyList());
+ when(issueFilterDao.selectByUser(eq("john"))).thenReturn(Collections.<IssueFilterDto> emptyList());
when(issueFilterDao.selectSharedFilters()).thenReturn(newArrayList(new IssueFilterDto().setId(1L).setName("My Issue").setUserLogin("henry").setShared(true)));
DefaultIssueFilter issueFilter = new DefaultIssueFilter().setName("My Issue").setShared(true);
try {
@@ -548,7 +548,7 @@ public class IssueFilterServiceTest {
when(issueFilterDao.selectSharedFilters()).thenReturn(newArrayList(
new IssueFilterDto().setId(1L).setName("My Issue").setUserLogin("john").setShared(true),
new IssueFilterDto().setId(2L).setName("Project Issues").setUserLogin("arthur").setShared(true)
- ));
+ ));
List<DefaultIssueFilter> results = service.findSharedFiltersWithoutUserFilters(userSession);
assertThat(results).hasSize(1);
@@ -565,16 +565,22 @@ public class IssueFilterServiceTest {
}
@Test
- public void should_find_empty_favourite_issue_filter_if_not_logged() {
+ public void should_not_find_favourite_issue_filter_if_not_logged() {
UserSession userSession = MockUserSession.create().setLogin(null);
- assertThat(service.findFavoriteFilters(userSession)).isEmpty();
+
+ try {
+ service.findFavoriteFilters(userSession);
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(UnauthorizedException.class).hasMessage("User is not logged in");
+ }
}
@Test
public void should_add_favourite_issue_filter_id() {
when(issueFilterDao.selectById(1L)).thenReturn(new IssueFilterDto().setId(1L).setName("My Issues").setUserLogin("john").setData("componentRoots=struts"));
// The filter is not in the favorite list --> add to favorite
- when(issueFilterFavouriteDao.selectByFilterId(1L)).thenReturn(Collections.<IssueFilterFavouriteDto>emptyList());
+ when(issueFilterFavouriteDao.selectByFilterId(1L)).thenReturn(Collections.<IssueFilterFavouriteDto> emptyList());
ArgumentCaptor<IssueFilterFavouriteDto> issueFilterFavouriteDtoCaptor = ArgumentCaptor.forClass(IssueFilterFavouriteDto.class);
service.toggleFavouriteIssueFilter(1L, userSession);
@@ -589,7 +595,7 @@ public class IssueFilterServiceTest {
public void should_add_favourite_on_shared_filter() {
when(issueFilterDao.selectById(1L)).thenReturn(new IssueFilterDto().setId(1L).setName("My Issues").setUserLogin("arthur").setShared(true));
// The filter is not in the favorite list --> add to favorite
- when(issueFilterFavouriteDao.selectByFilterId(1L)).thenReturn(Collections.<IssueFilterFavouriteDto>emptyList());
+ when(issueFilterFavouriteDao.selectByFilterId(1L)).thenReturn(Collections.<IssueFilterFavouriteDto> emptyList());
ArgumentCaptor<IssueFilterFavouriteDto> issueFilterFavouriteDtoCaptor = ArgumentCaptor.forClass(IssueFilterFavouriteDto.class);
service.toggleFavouriteIssueFilter(1L, userSession);
@@ -660,10 +666,10 @@ public class IssueFilterServiceTest {
if (o != null && o instanceof IssueFilterDto) {
IssueFilterDto otherFilter = (IssueFilterDto) o;
return ObjectUtils.equals(referenceFilter.isShared(), otherFilter.isShared())
- && ObjectUtils.equals(referenceFilter.getUserLogin(), otherFilter.getUserLogin())
- && ObjectUtils.equals(referenceFilter.getDescription(), otherFilter.getDescription())
- && ObjectUtils.equals(referenceFilter.getName(), otherFilter.getName())
- && ObjectUtils.equals(referenceFilter.getData(), otherFilter.getData());
+ && ObjectUtils.equals(referenceFilter.getUserLogin(), otherFilter.getUserLogin())
+ && ObjectUtils.equals(referenceFilter.getDescription(), otherFilter.getDescription())
+ && ObjectUtils.equals(referenceFilter.getName(), otherFilter.getName())
+ && ObjectUtils.equals(referenceFilter.getData(), otherFilter.getData());
}
return false;
}