use of org.finra.herd.model.api.xml.StorageCreateRequest 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.StorageCreateRequest 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.StorageCreateRequest in project herd by FINRAOS.
the class StorageServiceTest method testCreateStorageMissingRequiredParameters.
@Test
public void testCreateStorageMissingRequiredParameters() {
// Try to create a storage without specifying a storage name.
try {
storageService.createStorage(new StorageCreateRequest(BLANK_TEXT, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A storage name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageCreateRequest in project herd by FINRAOS.
the class StorageServiceTest method testCreateStorageInvalidParameters.
@Test
public void testCreateStorageInvalidParameters() {
// Try to create a storage instance when storage platform name contains a forward slash character.
try {
storageService.createStorage(new StorageCreateRequest(STORAGE_NAME, addSlash(STORAGE_PLATFORM_CODE), NO_ATTRIBUTES));
fail("Should throw an IllegalArgumentException when storage platform name contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Storage platform name can not contain a forward slash character.", e.getMessage());
}
// Try to create a storage instance when storage name contains a forward slash character.
try {
storageService.createStorage(new StorageCreateRequest(addSlash(DATA_PROVIDER_NAME), STORAGE_PLATFORM_CODE, NO_ATTRIBUTES));
fail("Should throw an IllegalArgumentException when storage name contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Storage name can not contain a forward slash character.", e.getMessage());
}
}
Aggregations