use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.
the class StorageServiceTest method testCreateStorageMissingOptionalParameters.
@Test
public void testCreateStorageMissingOptionalParameters() {
// Create and persist a valid storage without specifying optional parameters.
StorageCreateRequest request = getNewStorageCreateRequest();
request.setAttributes(null);
Storage result = storageService.createStorage(request);
// Validate the results.
assertEquals(new Storage(request.getName(), request.getStoragePlatformName(), NO_ATTRIBUTES), result);
}
use of org.finra.herd.model.api.xml.Storage 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()));
}
use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.
the class StorageServiceTest method testUpdateStorageAttributesStorageHasDuplicateAttributes.
@Test
public void testUpdateStorageAttributesStorageHasDuplicateAttributes() {
// Create and persist a valid storage.
StorageCreateRequest request = getNewStorageCreateRequest();
Storage storage = storageService.createStorage(request);
// Add a duplicate attribute to the storage.
StorageEntity storageEntity = storageDao.getStorageByName(storage.getName());
StorageAttributeEntity storageAttributeEntity = new StorageAttributeEntity();
storageAttributeEntity.setStorage(storageEntity);
storageAttributeEntity.setName(request.getAttributes().get(0).getName().toUpperCase());
storageEntity.getAttributes().add(storageAttributeEntity);
storageDao.saveAndRefresh(storageEntity);
// Try to update attributes for the storage.
try {
storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
} catch (IllegalStateException e) {
assertEquals(String.format("Found duplicate attribute with name \"%s\" for \"%s\" storage.", request.getAttributes().get(0).getName().toLowerCase(), storage.getName()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.
the class BusinessObjectDataHelperTest method getStorageUnitByStorageName.
@Test
public void getStorageUnitByStorageName() {
// Create business object data with several test storage units.
BusinessObjectData businessObjectData = new BusinessObjectData();
List<String> testStorageNames = Arrays.asList("Storage_1", "storage-2", "STORAGE3");
List<StorageUnit> storageUnits = new ArrayList<>();
businessObjectData.setStorageUnits(storageUnits);
for (String testStorageName : testStorageNames) {
StorageUnit storageUnit = new StorageUnit();
storageUnits.add(storageUnit);
Storage storage = new Storage();
storageUnit.setStorage(storage);
storage.setName(testStorageName);
}
// Validate that we can find all storage units regardless of the storage name case.
for (String testStorageName : testStorageNames) {
assertEquals(testStorageName, businessObjectDataHelper.getStorageUnitByStorageName(businessObjectData, testStorageName).getStorage().getName());
assertEquals(testStorageName, businessObjectDataHelper.getStorageUnitByStorageName(businessObjectData, testStorageName.toUpperCase()).getStorage().getName());
assertEquals(testStorageName, businessObjectDataHelper.getStorageUnitByStorageName(businessObjectData, testStorageName.toLowerCase()).getStorage().getName());
}
}
use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method getNewStorage.
/**
* Gets a new storage object with the specified information.
*
* @param storageName the storage name.
*
* @return the newly created storage.
*/
private Storage getNewStorage(String storageName) {
Storage storage = new Storage();
storage.setName(storageName);
storage.setStoragePlatformName(StoragePlatformEntity.S3);
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket"));
/*
* Set the KMS key attribute if the storage name contains ignore case the word "KMS" (ex. S3_MANAGED_KMS)
*/
if (storageName.toLowerCase().contains("kms")) {
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "testKmsKeyId"));
}
storage.setAttributes(attributes);
return storage;
}
Aggregations