Search in sources :

Example 6 with StorageKey

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

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

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

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

the class StorageServiceTest method testGetStorage.

@Test
public void testGetStorage() {
    // Create and persist a valid storage.
    Storage storage = storageService.createStorage(getNewStorageCreateRequest());
    // Retrieve the storage by its name.
    Storage result = storageService.getStorage(new StorageKey(storage.getName()));
    // Validate the results.
    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 10 with StorageKey

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

the class StorageServiceTest method testDeleteStorage.

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