@Test public void getPermittedUsersForSearch() { when(sharedToUserRepository.findBySavedSearch_Id(anyLong())).thenReturn(Collections.singleton(mock(SharedToUser.class))); assertThat(controller.getPermissionsForSearch(1L, null), not(empty())); }
@RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody public Set<SharedToUser> getPermissionsForSearch( @PathVariable(SEARCH_ID_PARAM) final Long searchId, @RequestParam(value = USERNAME_PARAM, required = false) final String username ) { return username != null ? sharedToUserRepository.findByUsernameAndSearchId(username, searchId) : sharedToUserRepository.findBySavedSearch_Id(searchId); }
SharedToUserController { @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody public Set<SharedToUser> getPermissionsForSearch( @PathVariable(SEARCH_ID_PARAM) final Long searchId, @RequestParam(value = USERNAME_PARAM, required = false) final String username ) { return username != null ? sharedToUserRepository.findByUsernameAndSearchId(username, searchId) : sharedToUserRepository.findBySavedSearch_Id(searchId); } }
SharedToUserController { @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody public Set<SharedToUser> getPermissionsForSearch( @PathVariable(SEARCH_ID_PARAM) final Long searchId, @RequestParam(value = USERNAME_PARAM, required = false) final String username ) { return username != null ? sharedToUserRepository.findByUsernameAndSearchId(username, searchId) : sharedToUserRepository.findBySavedSearch_Id(searchId); } @Autowired  SharedToUserController(
            final SharedToUserService sharedToUserService,
            final SharedToUserRepository sharedToUserRepository,
            final UserEntityService userEntityService
    ); }
SharedToUserController { @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody public Set<SharedToUser> getPermissionsForSearch( @PathVariable(SEARCH_ID_PARAM) final Long searchId, @RequestParam(value = USERNAME_PARAM, required = false) final String username ) { return username != null ? sharedToUserRepository.findByUsernameAndSearchId(username, searchId) : sharedToUserRepository.findBySavedSearch_Id(searchId); } @Autowired  SharedToUserController(
            final SharedToUserService sharedToUserService,
            final SharedToUserRepository sharedToUserRepository,
            final UserEntityService userEntityService
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody Set<SharedToUser> getPermissionsForSearch(
            @PathVariable(SEARCH_ID_PARAM) final Long searchId,
            @RequestParam(value = USERNAME_PARAM, required = false) final String username
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = {RequestMethod.PUT, RequestMethod.POST}) @ResponseBody SharedToUser save(
            @RequestBody final SharedToUser sharedToUser,
            @PathVariable("searchId") final long searchId
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}/{userId}", method = RequestMethod.PUT) @ResponseBody SharedToUser save(
            @RequestBody final SharedToUser sharedToUser,
            @PathVariable("searchId") final long searchId,
            @PathVariable("userId") final long userId
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}/{userId}", method = RequestMethod.DELETE) @ResponseBody @ResponseStatus(HttpStatus.NO_CONTENT) void delete(
            @PathVariable("searchId") final long searchId,
            @PathVariable("userId") final long userId
    ); }
SharedToUserController { @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody public Set<SharedToUser> getPermissionsForSearch( @PathVariable(SEARCH_ID_PARAM) final Long searchId, @RequestParam(value = USERNAME_PARAM, required = false) final String username ) { return username != null ? sharedToUserRepository.findByUsernameAndSearchId(username, searchId) : sharedToUserRepository.findBySavedSearch_Id(searchId); } @Autowired  SharedToUserController(
            final SharedToUserService sharedToUserService,
            final SharedToUserRepository sharedToUserRepository,
            final UserEntityService userEntityService
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = RequestMethod.GET) @ResponseBody Set<SharedToUser> getPermissionsForSearch(
            @PathVariable(SEARCH_ID_PARAM) final Long searchId,
            @RequestParam(value = USERNAME_PARAM, required = false) final String username
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}", method = {RequestMethod.PUT, RequestMethod.POST}) @ResponseBody SharedToUser save(
            @RequestBody final SharedToUser sharedToUser,
            @PathVariable("searchId") final long searchId
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}/{userId}", method = RequestMethod.PUT) @ResponseBody SharedToUser save(
            @RequestBody final SharedToUser sharedToUser,
            @PathVariable("searchId") final long searchId,
            @PathVariable("userId") final long userId
    ); @RequestMapping(value = PERMISSIONS_PATH + "/{searchId}/{userId}", method = RequestMethod.DELETE) @ResponseBody @ResponseStatus(HttpStatus.NO_CONTENT) void delete(
            @PathVariable("searchId") final long searchId,
            @PathVariable("userId") final long userId
    );  }