TagsApi { @ApiOperation( value = "Get tags", notes = "", nickname = "getTags") @RequestMapping( produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "List of tags.") }) @ResponseBody public List<org.fao.geonet.domain.MetadataCategory> getTags( ) throws Exception { return categoryRepository.findAll(); }  @ApiOperation( value = "Get tags", notes = "", nickname = "getTags") @RequestMapping( produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "List of tags.") }) @ResponseBody List<org.fao.geonet.domain.MetadataCategory> getTags(
    ); @ApiOperation( value = "Create a tag", notes = "If labels are not defined, a default label is created " + "with the category name for all languages.", nickname = "putTag") @RequestMapping( method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE } ) @ResponseStatus(HttpStatus.CREATED) @ApiResponses(value = { @ApiResponse(code = 201, message = "Tag created. Return the new tag identifier."), @ApiResponse(code = 403, message = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN) }) @PreAuthorize("hasRole('UserAdmin')") ResponseEntity<Integer> putTag(
        @ApiParam(
            name = "category"
        )
        @RequestBody
            MetadataCategory category
    ); @ApiOperation( value = "Get a tag", notes = "", nickname = "getTag") @RequestMapping( value = "/{tagIdentifier}", produces = { MediaType.APPLICATION_JSON_VALUE }, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Tag details.") }) @ResponseBody org.fao.geonet.domain.MetadataCategory getTag(
        @ApiParam(
            value = "Tag identifier",
            required = true
        )
        @PathVariable
            Integer tagIdentifier
    ); @ApiOperation( value = "Update a tag", notes = "", nickname = "updateTag") @RequestMapping( value = "/{tagIdentifier}", method = RequestMethod.PUT) @PreAuthorize("hasRole('UserAdmin')") @ResponseStatus(HttpStatus.NO_CONTENT) @ApiResponses(value = { @ApiResponse(code = 204, message = "Tag updated."), @ApiResponse(code = 403, message = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN) }) @ResponseBody ResponseEntity updateTag(
        @ApiParam(
            value = "Tag identifier",
            required = true
        )
        @PathVariable
            int tagIdentifier,
        @ApiParam(
            name = "category"
        )
        @RequestBody
            MetadataCategory category
    ); @ApiOperation( value = "Remove a tag", notes = "", nickname = "deleteTag") @RequestMapping( value = "/{tagIdentifier}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) @ApiResponses(value = { @ApiResponse(code = 204, message = "Tag removed."), @ApiResponse(code = 403, message = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN) }) @PreAuthorize("hasRole('UserAdmin')") ResponseEntity deleteTag(
        @ApiParam(
            value = "Tag identifier",
            required = true
        )
        @PathVariable
            Integer tagIdentifier
    );  }
@Test public void getTags() throws Exception { List<MetadataCategory> categories = _categoriesRepo.findAll(); this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); this.mockMvc.perform(get("/srv/api/tags") .accept(MediaType.parseMediaType("application/json"))) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(categories.size()))); }