private static final String PARAM_COMPONENT_KEY = "componentKey";
+ private static final String ANONYMOUS = null;
+
private static final String PROPERTY_COMPARABLE = "comparable";
private static final String PROPERTY_CONFIGURABLE = "configurable";
private static final String PROPERTY_HAS_ROLE_POLICY = "hasRolePolicy";
.prop("isFavorite", isFavourite(session, component, userSession));
List<DashboardDto> dashboards = activeDashboardDao.selectProjectDashboardsForUserLogin(session, userSession.login());
+ if (dashboards.isEmpty()) {
+ dashboards = activeDashboardDao.selectProjectDashboardsForUserLogin(session, ANONYMOUS);
+ }
writeDashboards(json, component, dashboards, userSession.locale());
if (snapshot != null) {
wsTester.newGetRequest("api/navigation", "component").setParam("componentKey", "polop").execute().assertJson(getClass(), "with_dashboards.json");
}
+ @Test
+ public void with_default_dashboards() throws Exception {
+ dbClient.componentDao().insert(session, ComponentTesting.newProjectDto("abcd")
+ .setKey("polop").setName("Polop"));
+ DashboardDto dashboard = new DashboardDto().setGlobal(false).setName("Anon Dashboard").setShared(true).setColumnLayout("100%");
+ dashboardDao.insert(dashboard);
+ activeDashboardDao.insert(new ActiveDashboardDto().setDashboardId(dashboard.getId()));
+ session.commit();
+
+ MockUserSession.set().setLogin("obiwan").addProjectUuidPermissions(UserRole.USER, "abcd");
+
+ wsTester = new WsTester(new NavigationWs(new ComponentNavigationAction(dbClient, activeDashboardDao,
+ new Views(), i18n, resourceTypes)));
+
+ wsTester.newGetRequest("api/navigation", "component").setParam("componentKey", "polop").execute().assertJson(getClass(), "with_default_dashboards.json");
+ }
+
@Test
public void with_extensions() throws Exception {
final String language = "xoo";