/** * 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)); }
/** * 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)); }
@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 testDeleteTagTypeTagTypeNotExists() { // Try to delete a tag type instance when tag type code is not specified. try { tagTypeService.deleteTagType(new TagTypeKey(I_DO_NOT_EXIST)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage()); } }
@Test public void testDeleteTagTypeMissingRequiredParameters() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Try to delete a tag type instance when tag type code is not specified. try { tagTypeService.deleteTagType(new TagTypeKey(BLANK_TEXT)); fail(); } catch (IllegalArgumentException e) { assertEquals("A tag type code must be specified.", e.getMessage()); } }
@Test public void testDeleteTagTypeUpperCaseParameters() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Delete the tag type using upper case input parameters. TagType resultTagType = tagTypeService.deleteTagType(new TagTypeKey(TAG_TYPE.toUpperCase())); // Validate the returned object. assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION), resultTagType); // Ensure that this tag type is no longer there. assertNull(tagTypeDao.getTagTypeByKey(resultTagType.getTagTypeKey())); }
@Test public void testDeleteTagTypeLowerCaseParameters() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Delete the tag type using lower case input parameters. TagType resultTagType = tagTypeService.deleteTagType(new TagTypeKey(TAG_TYPE.toLowerCase())); // Validate the returned object. assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION), resultTagType); // Ensure that this tag type is no longer there. assertNull(tagTypeDao.getTagTypeByKey(resultTagType.getTagTypeKey())); }
@Test public void testDeleteTagType() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Delete the tag type. TagType resultTagType = tagTypeService.deleteTagType(new TagTypeKey(TAG_TYPE)); // Validate the returned object. assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION), resultTagType); // Ensure that this tag type is no longer there. assertNull(tagTypeDao.getTagTypeByKey(resultTagType.getTagTypeKey())); }
@Test public void testDeleteTagTypeTrimParameters() { // Create and persist a tag type entity. tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION); // Delete the tag type using input parameters with leading and trailing empty spaces. TagType resultTagType = tagTypeService.deleteTagType(new TagTypeKey(addWhitespace(TAG_TYPE))); // Validate the returned object. assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION), resultTagType); // Ensure that this tag type is no longer there. assertNull(tagTypeDao.getTagTypeByKey(resultTagType.getTagTypeKey())); }