Search in sources :

Example 1 with StorageUpdateRequest

use of org.finra.herd.model.api.xml.StorageUpdateRequest in project herd by FINRAOS.

the class StorageServiceTest method testUpdateStorage.

@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);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageUpdateRequest(org.finra.herd.model.api.xml.StorageUpdateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 2 with StorageUpdateRequest

use of org.finra.herd.model.api.xml.StorageUpdateRequest in project herd by FINRAOS.

the class StorageServiceTest method testUpdateStorageStorageNoExists.

@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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) StorageUpdateRequest(org.finra.herd.model.api.xml.StorageUpdateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 3 with StorageUpdateRequest

use of org.finra.herd.model.api.xml.StorageUpdateRequest in project herd by FINRAOS.

the class StorageRestControllerTest method testUpdateStorage.

@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);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageUpdateRequest(org.finra.herd.model.api.xml.StorageUpdateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Aggregations

StorageKey (org.finra.herd.model.api.xml.StorageKey)3 StorageUpdateRequest (org.finra.herd.model.api.xml.StorageUpdateRequest)3 Test (org.junit.Test)3 Storage (org.finra.herd.model.api.xml.Storage)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1