/** * Creates a new tag type. * * @param request the information needed to create the tag type * * @return the created tag type */ @RequestMapping(value = TAG_TYPES_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAG_TYPES_POST) public TagType createTagType(@RequestBody TagTypeCreateRequest request) { return tagTypeService.createTagType(request); }
/** * Deletes an existing tag type by tag type code. * * @param tagTypeCode the tag type code * * @return the tag type that got deleted */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/{tagTypeCode}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_TAG_TYPES_DELETE) public TagType deleteTagType(@PathVariable("tagTypeCode") String tagTypeCode) { return tagTypeService.deleteTagType(new TagTypeKey(tagTypeCode)); }
/** * Gets an existing tag type by tag type code. * * @param tagTypeCode the tag type code * * @return the retrieved tag type */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/{tagTypeCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAG_TYPES_GET) public TagType getTagType(@PathVariable("tagTypeCode") String tagTypeCode) { return tagTypeService.getTagType(new TagTypeKey(tagTypeCode)); }
/** * Updates an existing tag type. * * @param tagTypeCode the tag type code * @param request the information needed to update the tag type * * @return the updated tag type */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/{tagTypeCode}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAG_TYPES_PUT) public TagType updateTagType(@PathVariable("tagTypeCode") String tagTypeCode, @RequestBody TagTypeUpdateRequest request) { return tagTypeService.updateTagType(new TagTypeKey(tagTypeCode), request); } }
/** * Retrieves all tag types existing in the system. For each tag type entity, the endpoint returns tag type key by default along with any other top-level * elements as specified by the "fields" query string parameter. The list of tag types returned by the endpoint is sorted alphabetically by tag type's order * value ascending. * * @param request the tag type search request. The request does not take any search keys or filters * @param fields the field options for the tag type search response. The valid field options are: displayName, tagTypeOrder and description * * @return the tag type search response */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/search", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAG_TYPES_SEARCH_POST) public TagTypeSearchResponse searchTagTypes(@RequestBody TagTypeSearchRequest request, @RequestParam(value = "fields", required = false, defaultValue = "") Set<String> fields) { return tagTypeService.searchTagTypes(request, fields); }
/** * Gets a list of tag type keys for all tag types defined in the system. * * @return the list of tag type keys */ @RequestMapping(value = TAG_TYPES_URI_PREFIX, method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAG_TYPES_ALL_GET) public TagTypeKeys getTagTypes() { return tagTypeService.getTagTypes(); }
/** * Updates an existing tag type. * * @param tagTypeCode the tag type code * @param request the information needed to update the tag type * * @return the updated tag type */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/{tagTypeCode}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAG_TYPES_PUT) public TagType updateTagType(@PathVariable("tagTypeCode") String tagTypeCode, @RequestBody TagTypeUpdateRequest request) { return tagTypeService.updateTagType(new TagTypeKey(tagTypeCode), request); } }
/** * Retrieves all tag types existing in the system. For each tag type entity, the endpoint returns tag type key by default along with any other top-level * elements as specified by the "fields" query string parameter. The list of tag types returned by the endpoint is sorted alphabetically by tag type's order * value ascending. * * @param request the tag type search request. The request does not take any search keys or filters * @param fields the field options for the tag type search response. The valid field options are: displayName, tagTypeOrder and description * * @return the tag type search response */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/search", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAG_TYPES_SEARCH_POST) public TagTypeSearchResponse searchTagTypes(@RequestBody TagTypeSearchRequest request, @RequestParam(value = "fields", required = false, defaultValue = "") Set<String> fields) { return tagTypeService.searchTagTypes(request, fields); }
/** * Gets a list of tag type keys for all tag types defined in the system. * * @return the list of tag type keys */ @RequestMapping(value = TAG_TYPES_URI_PREFIX, method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAG_TYPES_ALL_GET) public TagTypeKeys getTagTypes() { return tagTypeService.getTagTypes(); }
@Test public void testUpdateTagTypeUpperCaseParameters() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Update the tag type using upper case input parameters. TagType resultTagType = tagTypeService.updateTagType(new TagTypeKey(TAG_TYPE.toUpperCase()), new TagTypeUpdateRequest(TAG_TYPE_DISPLAY_NAME_2.toUpperCase(), TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2.toUpperCase())); // Validate the returned object. assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME_2.toUpperCase(), TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2.toUpperCase()), resultTagType); }
@Test public void testSearchTagTypesMissingRequiredParameters() { // Try to search tag types when tag type search request is not specified. try { tagTypeService.searchTagTypes(null, Sets.newHashSet(TagTypeServiceImpl.DISPLAY_NAME_FIELD, TagTypeServiceImpl.TAG_TYPE_ORDER_FIELD, TagTypeServiceImpl.DESCRIPTION_FIELD)); fail(); } catch (IllegalArgumentException e) { assertEquals("A tag type search request must be specified.", e.getMessage()); } }
/** * Deletes an existing tag type by tag type code. * * @param tagTypeCode the tag type code * * @return the tag type that got deleted */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/{tagTypeCode}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_TAG_TYPES_DELETE) public TagType deleteTagType(@PathVariable("tagTypeCode") String tagTypeCode) { return tagTypeService.deleteTagType(new TagTypeKey(tagTypeCode)); }
/** * Gets an existing tag type by tag type code. * * @param tagTypeCode the tag type code * * @return the retrieved tag type */ @RequestMapping(value = TAG_TYPES_URI_PREFIX + "/{tagTypeCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAG_TYPES_GET) public TagType getTagType(@PathVariable("tagTypeCode") String tagTypeCode) { return tagTypeService.getTagType(new TagTypeKey(tagTypeCode)); }
/** * Creates a new tag type. * * @param request the information needed to create the tag type * * @return the created tag type */ @RequestMapping(value = TAG_TYPES_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAG_TYPES_POST) public TagType createTagType(@RequestBody TagTypeCreateRequest request) { return tagTypeService.createTagType(request); }
@Test public void testGetTagTypes() throws Exception { TagTypeKeys tagTypeKeys = new TagTypeKeys(Arrays.asList(new TagTypeKey(TAG_TYPE))); when(tagTypeService.getTagTypes()).thenReturn(tagTypeKeys); // Retrieve a list of tag type keys. TagTypeKeys resultTagTypeKeys = tagTypeRestController.getTagTypes(); // Verify the external calls. verify(tagTypeService).getTagTypes(); verifyNoMoreInteractions(tagTypeService); // Validate the returned object. assertEquals(tagTypeKeys, resultTagTypeKeys); }
@Test public void testUpdateTagTypeLowerCaseParameters() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Update the tag type using lower case input parameters. TagType resultTagType = tagTypeService.updateTagType(new TagTypeKey(TAG_TYPE.toLowerCase()), new TagTypeUpdateRequest(TAG_TYPE_DISPLAY_NAME_2.toLowerCase(), TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2.toLowerCase())); // Validate the returned object. assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME_2.toLowerCase(), TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2.toLowerCase()), resultTagType); }
@Test public void testSearchTagTypesInvalidParameters() { // Try to search tag types using a un-supported search response field option. try { tagTypeService.searchTagTypes(new TagTypeSearchRequest(), Sets.newHashSet("INVALID_FIELD_OPTION")); fail(); } catch (IllegalArgumentException e) { assertEquals("Search response field \"invalid_field_option\" is not supported.", e.getMessage()); } }
@Test public void testDeleteTagType() throws Exception { TagTypeKey tagTypeKey = new TagTypeKey(TAG_TYPE); TagType tagType = new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); when(tagTypeService.deleteTagType(tagTypeKey)).thenReturn(tagType); // Delete this tag type. TagType deletedTagType = tagTypeRestController.deleteTagType(TAG_TYPE); // Verify the external calls. verify(tagTypeService).deleteTagType(tagTypeKey); verifyNoMoreInteractions(tagTypeService); // Validate the returned object. assertEquals(tagType, deletedTagType); }
@Test public void testGetTagType() throws Exception { TagTypeKey tagTypeKey = new TagTypeKey(TAG_TYPE); TagType tagType = new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); when(tagTypeService.getTagType(tagTypeKey)).thenReturn(tagType); // Retrieve the tag type. TagType resultTagType = tagTypeRestController.getTagType(TAG_TYPE); // Verify the external calls. verify(tagTypeService).getTagType(tagTypeKey); verifyNoMoreInteractions(tagTypeService); // Validate the returned object. assertEquals(tagType, resultTagType); }
@Test public void testCreateTagType() throws Exception { TagTypeCreateRequest request = new TagTypeCreateRequest(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); TagType tagType = new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); when(tagTypeService.createTagType(request)).thenReturn(tagType); // Create a tag type. TagType resultTagType = tagTypeRestController .createTagType(new TagTypeCreateRequest(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION)); // Verify the external calls. verify(tagTypeService).createTagType(request); verifyNoMoreInteractions(tagTypeService); // Validate the returned object. assertEquals(tagType, resultTagType); }