Search in sources :

Example 1 with StorageKey

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

the class StorageRestControllerTest method testUpdateStorageAttributes.

@Test
public void testUpdateStorageAttributes() {
    // Create a storage key.
    StorageKey storageKey = new StorageKey(STORAGE_NAME);
    // Create a storage update request.
    StorageAttributesUpdateRequest storageAttributesUpdateRequest = new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes());
    // Create a storage.
    Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, businessObjectDefinitionServiceTestHelper.getNewAttributes());
    // Mock the external calls.
    when(storageService.updateStorageAttributes(storageKey, storageAttributesUpdateRequest)).thenReturn(storage);
    // Call the method under test.
    Storage result = storageRestController.updateStorageAttributes(STORAGE_NAME, storageAttributesUpdateRequest);
    // Verify the external calls.
    verify(storageService).updateStorageAttributes(storageKey, storageAttributesUpdateRequest);
    verifyNoMoreInteractions(storageService);
    // Validate the returned object.
    assertEquals(storage, result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageAttributesUpdateRequest(org.finra.herd.model.api.xml.StorageAttributesUpdateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 2 with StorageKey

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

the class StorageRestControllerTest method testGetStorage.

@Test
public void testGetStorage() {
    // 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.getStorage(storageKey)).thenReturn(storage);
    // Call the method under test.
    Storage result = storageRestController.getStorage(STORAGE_NAME);
    // Verify the external calls.
    verify(storageService).getStorage(storageKey);
    verifyNoMoreInteractions(storageService);
    // Validate the returned object.
    assertEquals(storage, result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 3 with StorageKey

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

the class StorageRestControllerTest method testGetStorages.

@Test
public void testGetStorages() {
    // Get a list of storage keys.
    StorageKeys storageKeys = new StorageKeys(Arrays.asList(new StorageKey(STORAGE_NAME), new StorageKey(STORAGE_NAME_2)));
    // Mock the external calls.
    when(storageService.getAllStorage()).thenReturn(storageKeys);
    // Call the method under test.
    StorageKeys result = storageRestController.getStorages();
    // Verify the external calls.
    verify(storageService).getAllStorage();
    verifyNoMoreInteractions(storageService);
    // Validate the returned object.
    assertEquals(storageKeys, result);
}
Also used : StorageKeys(org.finra.herd.model.api.xml.StorageKeys) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 4 with StorageKey

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

the class StorageDaoTest method testGetAllStorage.

@Test
public void testGetAllStorage() {
    // Get a list of test storage keys.
    List<StorageKey> storageKeys = storageDaoTestHelper.getTestStorageKeys();
    // Create and persist storage entities.
    for (StorageKey storageKey : storageKeys) {
        storageDaoTestHelper.createStorageEntity(storageKey.getStorageName());
    }
    // Retrieve a list of storage keys for all storage registered in the system.
    List<StorageKey> result = storageDao.getAllStorage();
    // Validate the results.
    assertNotNull(result);
    assertTrue(result.containsAll(storageDaoTestHelper.getTestStorageKeys()));
}
Also used : StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 5 with StorageKey

use of org.finra.herd.model.api.xml.StorageKey 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)

Aggregations

StorageKey (org.finra.herd.model.api.xml.StorageKey)19 Test (org.junit.Test)18 Storage (org.finra.herd.model.api.xml.Storage)10 StorageAttributesUpdateRequest (org.finra.herd.model.api.xml.StorageAttributesUpdateRequest)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 StorageCreateRequest (org.finra.herd.model.api.xml.StorageCreateRequest)3 StorageUpdateRequest (org.finra.herd.model.api.xml.StorageUpdateRequest)3 StorageKeys (org.finra.herd.model.api.xml.StorageKeys)2 StorageEntity (org.finra.herd.model.jpa.StorageEntity)2 ArrayList (java.util.ArrayList)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Command (org.finra.herd.core.Command)1 StorageAttributeEntity (org.finra.herd.model.jpa.StorageAttributeEntity)1 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)1 Ignore (org.junit.Ignore)1