SelectionsApi { @ApiOperation(value = "Get current selection", nickname = "getSelection") @RequestMapping( method = RequestMethod.GET, value = "/{bucket}", produces = { MediaType.APPLICATION_JSON_VALUE }) public @ResponseBody @ResponseStatus(HttpStatus.OK) Set<String> get( @ApiParam(value = "Bucket name", required = true, example = "metadata") @PathVariable String bucket, @ApiIgnore HttpSession httpSession ) throws Exception { SelectionManager selectionManager = SelectionManager.getManager(ApiUtils.getUserSession(httpSession)); synchronized (selectionManager.getSelection(bucket)) { return selectionManager.getSelection(bucket); } }  @ApiOperation(value = "Get current selection", nickname = "getSelection") @RequestMapping( method = RequestMethod.GET, value = "/{bucket}", produces = { MediaType.APPLICATION_JSON_VALUE }) @ResponseBody @ResponseStatus(HttpStatus.OK) Set<String> get(
        @ApiParam(value = "Bucket name",
            required = true,
            example = "metadata")
        @PathVariable
            String bucket,
        @ApiIgnore
        HttpSession httpSession
    ); @ApiOperation(value = "Select one or more items", nickname = "addToSelection") @RequestMapping( method = RequestMethod.PUT, value = "/{bucket}", produces = { MediaType.APPLICATION_JSON_VALUE }) @ResponseBody ResponseEntity<Integer> add(
        @ApiParam(value = "Bucket name",
            required = true,
            example = "metadata")
        @PathVariable
            String bucket,
        @ApiParam(value = "One or more record UUIDs. If null, select all in current search if bucket name is 'metadata' (TODO: remove this limitation?).",
            required = false)
        @RequestParam(required = false)
            String[] uuid,
        @ApiIgnore
        HttpSession httpSession,
        @ApiIgnore
        HttpServletRequest request
    ); @ApiOperation(value = "Clear selection or remove items", nickname = "clearSelection") @RequestMapping( method = RequestMethod.DELETE, value = "/{bucket}", produces = { MediaType.APPLICATION_JSON_VALUE }) @ResponseBody ResponseEntity<Integer> clear(
        @ApiParam(value = ApiParams.API_PARAM_BUCKET_NAME,
            required = true,
            example = "metadata")
        @PathVariable
            String bucket,
        @ApiParam(
            value = API_PARAM_RECORD_UUIDS,
            required = false)
        @RequestParam(required = false)
            String[] uuid,
        @ApiIgnore
        HttpSession httpSession,
        @ApiIgnore
        HttpServletRequest request
    );  }
@Test public void getSelection() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); UserSession session = ApiUtils.getUserSession( this.mockHttpSession); int selected = SelectionManager.getManager(session).getSelection(SelectionManager.SELECTION_METADATA).size(); this.mockMvc.perform(get("/srv/api/selections/" + SelectionManager.SELECTION_METADATA) .session(this.mockHttpSession) .accept(MediaType.parseMediaType("application/json"))) .andExpect(status().isOk()) .andExpect(content().contentType(API_JSON_EXPECTED_ENCODING)) .andExpect(jsonPath("$", hasSize(selected))); }