Commit add3ea76 authored by oleg.pahhomov's avatar oleg.pahhomov

SA0140-537 | Update pin/unpin testcases

parent b001a6b2
package ee.stat.dashboard.controller;
import ee.stat.dashboard.AssertUtil;
import ee.stat.dashboard.model.widget.back.enums.GraphTypeEnum;
import ee.stat.dashboard.model.widget.back.enums.Language;
import ee.stat.dashboard.service.dashboard.dto.DashboardResponse;
......@@ -10,6 +11,7 @@ import ee.stat.dashboard.service.widget.widget.dto.UserGraphTypeDto;
import ee.stat.dashboard.service.widget.widget.dto.UserWidgetDto;
import ee.stat.dashboard.service.widget.widget.dto.WidgetResponse;
import ee.stat.dashboard.validator.strategy.WidgetValidationStrategy;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -21,6 +23,7 @@ import static ee.stat.dashboard.AssertUtil.USER_REGULAR;
import static ee.stat.dashboard.AssertUtil.getTourismAccomodationWidget;
import static ee.stat.dashboard.AssertUtil.list_size;
import static ee.stat.dashboard.validator.Widget_AccomodationValidator.assertAccomodationWidget;
import static org.apache.commons.collections4.CollectionUtils.isEmpty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
......@@ -71,9 +74,10 @@ public class DashboardWidgetController_SavePreferences_Test extends DashboardWid
ResponseEntity<Response<UserWidgetDto>> pinned = updatePin(USER_REGULAR, DASHBOARD_1, accommodationId, pin());
assertEquals(HttpStatus.OK, pinned.getStatusCode());
//creates my dashboard if it didn't exist
//creates my dashboard if it didn't exist, dashboard has widgets
DashboardResponse myDashboard = getMyDashboard(Language.ET, USER_REGULAR);
assertNotNull(myDashboard.getWidgets());
list_size(myDashboard.getWidgets(), 1);
assertEquals(accommodationId, AssertUtil.first(myDashboard.getWidgets()).getId());
//my dashboard widget has same preferences as old widget
WidgetResponse myDashboardWidget = getWidget(myDashboard.getId(), accommodationId, Language.ET, GraphTypeEnum.line, USER_REGULAR);
......@@ -90,8 +94,9 @@ public class DashboardWidgetController_SavePreferences_Test extends DashboardWid
ResponseEntity<Response<UserWidgetDto>> unpinned = updatePin(USER_REGULAR, DASHBOARD_1, accommodationId, unpin());
assertEquals(HttpStatus.OK, unpinned.getStatusCode());
//my dashboard is still there
getMyDashboard(Language.ET, USER_REGULAR);
//my dashboard is still there, but it has no widgets
DashboardResponse myDashboard1 = getMyDashboard(Language.ET, USER_REGULAR);
list_size(myDashboard1.getWidgets(), 0);
//my dashboard widget is not there 404
getWidget_notFound(myDashboard.getId(), accommodationId, Language.ET, GraphTypeEnum.line, USER_REGULAR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment