UserDashboardRestController { @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/search/getDefaultDashboardForCurrentUser") @PreAuthorize("hasRole('ROLE_PROCURING_ENTITY')") @ResponseBody public ResponseEntity<?> getDefaultDashboardForCurrentUser(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { UserDashboard dashboard = repository.getDefaultDashboardForPersonId(getCurrentAuthenticatedPerson().getId()); if (dashboard == null) { return ResponseEntity.ok().build(); } Resource<Object> resource = persistentEntityResourceAssembler.toResource(dashboard); return ResponseEntity.ok(resource); } @Autowired  UserDashboardRestController(UserDashboardRepository repo); @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/search/getDefaultDashboardForCurrentUser") @PreAuthorize("hasRole('ROLE_PROCURING_ENTITY')") @ResponseBody ResponseEntity<?> getDefaultDashboardForCurrentUser(PersistentEntityResourceAssembler persistentEntityResourceAssembler); @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/getCurrentAuthenticatedUserDetails") @ResponseBody ResponseEntity<?> getCurrentAuthenticatedUserDetails(PersistentEntityResourceAssembler persistentEntityResourceAssembler); @SuppressWarnings({ "unchecked", "rawtypes" }) @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/search/getDashboardsForCurrentUser") @PreAuthorize("hasRole('ROLE_PROCURING_ENTITY')") @ResponseBody PagedResources<Resource<UserDashboard>> getDashboardsForCurrentUser(Pageable page,
            PersistentEntityResourceAssembler persistentEntityResourceAssembler); @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/saveDashboardForCurrentUser") @PreAuthorize("hasRole('ROLE_PROCURING_ENTITY')") ResponseEntity<Void> saveDashboardForCurrentUser(@ModelAttribute @Valid UserDashboard userDashboard); @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, value = "/userDashboards/saveDashboard") @PreAuthorize("hasRole('ROLE_ADMIN')") ResponseEntity<Void> saveDashboard(@ModelAttribute @Valid UserDashboard userDashboard);  }
@Test @WithUserDetails(value = "admin", userDetailsServiceBeanName = "testUserDetailsAdminProcuringEntity") public void getDefaultDashboardForCurrentUserTest() { ResponseEntity<?> responseEntity = userDashboardRestController.getDefaultDashboardForCurrentUser(persistentEntityResourceAssembler); Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); }