Search in sources :

Example 1 with StorageCreateRequest

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

the class StorageRestControllerTest method testCreateStorage.

@Test
public void testCreateStorage() {
    // Create a storage create request.
    StorageCreateRequest storageCreateRequest = new StorageCreateRequest(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES);
    // Create a storage.
    Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES);
    // Mock the external calls.
    when(storageService.createStorage(storageCreateRequest)).thenReturn(storage);
    // Call the method under test.
    Storage result = storageRestController.createStorage(storageCreateRequest);
    // Verify the external calls.
    verify(storageService).createStorage(storageCreateRequest);
    verifyNoMoreInteractions(storageService);
    // Validate the returned object.
    assertEquals(storage, result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageCreateRequest(org.finra.herd.model.api.xml.StorageCreateRequest) Test(org.junit.Test)

Example 2 with StorageCreateRequest

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

the class StorageServiceTest method testCreateStorageStorageAlreadyExists.

@Test
public void testCreateStorageStorageAlreadyExists() {
    // Create and persist a valid storage.
    StorageCreateRequest storageCreateRequest = getNewStorageCreateRequest();
    storageService.createStorage(storageCreateRequest);
    // Try creating that storage again which is invalid since it already exists.
    try {
        storageService.createStorage(storageCreateRequest);
        fail();
    } catch (AlreadyExistsException e) {
        assertEquals(String.format("Storage with name \"%s\" already exists.", storageCreateRequest.getName()), e.getMessage());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) StorageCreateRequest(org.finra.herd.model.api.xml.StorageCreateRequest) Test(org.junit.Test)

Example 3 with StorageCreateRequest

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

the class StorageServiceTest method testUpdateStorageAttributes.

@Test
public void testUpdateStorageAttributes() {
    // Create and persist a valid storage.
    StorageCreateRequest request = getNewStorageCreateRequest();
    Storage storage = storageService.createStorage(request);
    // Update attributes for the storage.
    Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
    // Validate the results.
    assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), businessObjectDefinitionServiceTestHelper.getNewAttributes2()), result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageAttributesUpdateRequest(org.finra.herd.model.api.xml.StorageAttributesUpdateRequest) StorageCreateRequest(org.finra.herd.model.api.xml.StorageCreateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 4 with StorageCreateRequest

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

the class StorageServiceTest method testUpdateStorageAttributesRemoveAllAttributes.

@Test
public void testUpdateStorageAttributesRemoveAllAttributes() {
    // Create and persist a valid storage.
    StorageCreateRequest request = getNewStorageCreateRequest();
    Storage storage = storageService.createStorage(request);
    // Update attributes for the storage.
    Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(NO_ATTRIBUTES));
    // Validate the results.
    assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), NO_ATTRIBUTES), result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageAttributesUpdateRequest(org.finra.herd.model.api.xml.StorageAttributesUpdateRequest) StorageCreateRequest(org.finra.herd.model.api.xml.StorageCreateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 5 with StorageCreateRequest

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

the class StorageServiceTest method testCreateStorage.

@Test
public void testCreateStorage() {
    // Create and persist a valid storage.
    StorageCreateRequest request = getNewStorageCreateRequest();
    Storage result = storageService.createStorage(request);
    // Validate the results.
    assertEquals(new Storage(request.getName(), request.getStoragePlatformName(), request.getAttributes()), result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageCreateRequest(org.finra.herd.model.api.xml.StorageCreateRequest) Test(org.junit.Test)

Aggregations

StorageCreateRequest (org.finra.herd.model.api.xml.StorageCreateRequest)9 Test (org.junit.Test)9 Storage (org.finra.herd.model.api.xml.Storage)6 StorageAttributesUpdateRequest (org.finra.herd.model.api.xml.StorageAttributesUpdateRequest)3 StorageKey (org.finra.herd.model.api.xml.StorageKey)3 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 StorageAttributeEntity (org.finra.herd.model.jpa.StorageAttributeEntity)1 StorageEntity (org.finra.herd.model.jpa.StorageEntity)1