/** * Deletes an existing partition key group by name. * * @param partitionKeyGroupName the partition key group name * * @return the partition key group that got deleted */ @RequestMapping(value = PARTITION_KEY_GROUPS_URI_PREFIX + "/{partitionKeyGroupName}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_PARTITION_KEY_GROUPS_DELETE) public PartitionKeyGroup deletePartitionKeyGroup(@PathVariable("partitionKeyGroupName") String partitionKeyGroupName) { PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey(); partitionKeyGroupKey.setPartitionKeyGroupName(partitionKeyGroupName); return partitionKeyGroupService.deletePartitionKeyGroup(partitionKeyGroupKey); }
/** * Deletes an existing partition key group by name. * * @param partitionKeyGroupName the partition key group name * * @return the partition key group that got deleted */ @RequestMapping(value = PARTITION_KEY_GROUPS_URI_PREFIX + "/{partitionKeyGroupName}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_PARTITION_KEY_GROUPS_DELETE) public PartitionKeyGroup deletePartitionKeyGroup(@PathVariable("partitionKeyGroupName") String partitionKeyGroupName) { PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey(); partitionKeyGroupKey.setPartitionKeyGroupName(partitionKeyGroupName); return partitionKeyGroupService.deletePartitionKeyGroup(partitionKeyGroupKey); }
@Test public void testDeletePartitionKeyGroup() { PartitionKeyGroup partitionKeyGroup = new PartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP)); PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey(PARTITION_KEY_GROUP); when(partitionKeyGroupService.deletePartitionKeyGroup(partitionKeyGroupKey)).thenReturn(partitionKeyGroup); // Delete this partition key group. PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupRestController.deletePartitionKeyGroup(PARTITION_KEY_GROUP); // Verify the external calls. verify(partitionKeyGroupService).deletePartitionKeyGroup(partitionKeyGroupKey); verifyNoMoreInteractions(partitionKeyGroupService); // Validate the returned object. assertEquals(partitionKeyGroup, deletedPartitionKeyGroup); }
@Test public void testDeletePartitionKeyGroupMissingRequiredParameters() { // Try to perform a delete without specifying partition key group name. try { partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(BLANK_TEXT)); fail("Should throw an IllegalArgumentException when partition key group is not specified."); } catch (IllegalArgumentException e) { assertEquals("A partition key group name must be specified.", e.getMessage()); } }
@Test public void testDeletePartitionKeyGroupUpperCaseParameters() { // Create and persist a partition key group entity with a lowercase name. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toLowerCase()); // Delete this partition key group by passing partition key group name in upper case. PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase())); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP.toLowerCase(), deletedPartitionKeyGroup); // Ensure that this partition key group is no longer there. assertNull( partitionKeyGroupDao.getPartitionKeyGroupByKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP.toLowerCase()))); }
@Test public void testDeletePartitionKeyGroupLowerCaseParameters() { // Create and persist a partition key group entity with an uppercase name. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toUpperCase()); // Validate that this partition key group exists. partitionKeyGroupService.getPartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase())); // Retrieve the partition key group by passing partition key group name in lower case. PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toLowerCase())); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP.toUpperCase(), deletedPartitionKeyGroup); // Ensure that this partition key group is no longer there. assertNull( partitionKeyGroupDao.getPartitionKeyGroupByKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase()))); }
@Test public void testDeletePartitionKeyGroupUsedByFormat() { // Create a partition key group. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP); // Create a business object format that uses this partition key group. businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, true, PARTITION_KEY, PARTITION_KEY_GROUP); // Try to delete this partition key group. try { partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP)); fail("Suppose to throw an IllegalArgumentException when partition key group is used by business object format."); } catch (IllegalArgumentException e) { assertEquals(String.format("Can not delete \"%s\" partition key group since it is being used by a business object format.", PARTITION_KEY_GROUP), e.getMessage()); } }
@Test public void testDeletePartitionKeyGroupExpectedPartitionValuesPresent() { // Create and persist a partition key group entity. PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP); // Add expected partition values to this partition key group. expectedPartitionValueDaoTestHelper.createExpectedPartitionValueProcessDatesForApril2014(PARTITION_KEY_GROUP); herdDao.saveAndRefresh(partitionKeyGroupEntity); // Delete this partition key group. PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP)); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, deletedPartitionKeyGroup); // Ensure that this partition key group is no longer there. assertNull(partitionKeyGroupDao.getPartitionKeyGroupByKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP))); }
@Test public void testDeletePartitionKeyGroup() { // Create and persist a partition key group entity. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP); // Validate that this partition key group exists. partitionKeyGroupService.getPartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP)); // Delete this partition key group. PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP)); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, deletedPartitionKeyGroup); // Ensure that this partition key group is no longer there. assertNull(partitionKeyGroupDao.getPartitionKeyGroupByKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP))); }
@Test public void testDeletePartitionKeyGroupTrimParameters() { // Create and persist a partition key group entity. partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP); // Validate that this partition key group exists. partitionKeyGroupService.getPartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP)); // Delete this partition key group by passing partition key group name with leading and trailing whitespace characters. PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(addWhitespace(PARTITION_KEY_GROUP))); // Validate the returned object. partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, deletedPartitionKeyGroup); // Ensure that this partition key group is no longer there. assertNull(partitionKeyGroupDao.getPartitionKeyGroupByKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP))); }