/** * Deletes an existing storage by name. * * @param storageName the storage name * * @return the storage information of the storage that got deleted */ @RequestMapping(value = STORAGE_URI_PREFIX + "/{storageName}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_STORAGES_DELETE) Storage deleteStorage(@PathVariable("storageName") String storageName) { return storageService.deleteStorage(new StorageKey(storageName)); }
/** * Deletes an existing storage by name. * * @param storageName the storage name * * @return the storage information of the storage that got deleted */ @RequestMapping(value = STORAGE_URI_PREFIX + "/{storageName}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_STORAGES_DELETE) Storage deleteStorage(@PathVariable("storageName") String storageName) { return storageService.deleteStorage(new StorageKey(storageName)); }
@Test public void testDeleteStorage() { // Create a storage key. StorageKey storageKey = new StorageKey(STORAGE_NAME); // Create a storage. Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Mock the external calls. when(storageService.deleteStorage(storageKey)).thenReturn(storage); // Call the method under test. Storage result = storageRestController.deleteStorage(STORAGE_NAME); // Verify the external calls. verify(storageService).deleteStorage(storageKey); verifyNoMoreInteractions(storageService); // Validate the returned object. assertEquals(storage, result); }
@Override public void execute() { // Delete the storage which is invalid because there still exists a storage unit entity that references it. StorageKey alternateKey = new StorageKey(storageUnitEntity.getStorage().getName()); storageService.deleteStorage(alternateKey); } });
@Test public void testDeleteStorageInvalidName() { // Try to delete a storage which doesn't exist. try { storageService.deleteStorage(new StorageKey(INVALID_VALUE)); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage()); } }
@Test public void testDeleteStorage() { // Create and persist a valid storage. Storage storage = storageService.createStorage(getNewStorageCreateRequest()); // Delete the storage. Storage result = storageService.deleteStorage(new StorageKey(storage.getName())); assertEquals(storage, result); // Retrieve the storage by its name and verify that it doesn't exist. assertNull(storageDao.getStorageByName(storage.getName())); }