/** * Updates an existing storage. * * @param storageName the name of the storage to update * @param storageUpdateRequest the information needed to update the storage * * @return the updated storage information */ @RequestMapping(value = STORAGE_URI_PREFIX + "/{storageName}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_STORAGES_PUT) Storage updateStorage(@PathVariable("storageName") String storageName, @RequestBody StorageUpdateRequest storageUpdateRequest) { return storageService.updateStorage(new StorageKey(storageName), storageUpdateRequest); }
/** * Updates an existing storage. * * @param storageName the name of the storage to update * @param storageUpdateRequest the information needed to update the storage * * @return the updated storage information */ @RequestMapping(value = STORAGE_URI_PREFIX + "/{storageName}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_STORAGES_PUT) Storage updateStorage(@PathVariable("storageName") String storageName, @RequestBody StorageUpdateRequest storageUpdateRequest) { return storageService.updateStorage(new StorageKey(storageName), storageUpdateRequest); }
@Test public void testUpdateStorage() { // Create a storage key. StorageKey storageKey = new StorageKey(STORAGE_NAME); // Create a storage update request. StorageUpdateRequest storageUpdateRequest = new StorageUpdateRequest(); // Create a storage. Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Mock the external calls. when(storageService.updateStorage(storageKey, storageUpdateRequest)).thenReturn(storage); // Call the method under test. Storage result = storageRestController.updateStorage(STORAGE_NAME, storageUpdateRequest); // Verify the external calls. verify(storageService).updateStorage(storageKey, storageUpdateRequest); verifyNoMoreInteractions(storageService); // Validate the returned object. assertEquals(storage, result); }
@Test public void testUpdateStorageStorageNoExists() { // Try to update a storage that doesn't yet exist. try { storageService.updateStorage(new StorageKey(INVALID_VALUE), new StorageUpdateRequest()); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage()); } }
@Test public void testUpdateStorage() { // Create a storage. Storage storage = storageService.createStorage(getNewStorageCreateRequest()); // Update the storage. // TODO: Update various attributes of the storage update request in the future when there is something to update. Storage result = storageService.updateStorage(new StorageKey(storage.getName()), new StorageUpdateRequest()); // Validate the results. // TODO: Add asserts to ensure fields that were update indeed got updated. assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), storage.getAttributes()), result); }