Search in sources :

Example 6 with StorageCreateRequest

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

Example 7 with StorageCreateRequest

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());
    }
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageAttributeEntity(org.finra.herd.model.jpa.StorageAttributeEntity) StorageAttributesUpdateRequest(org.finra.herd.model.api.xml.StorageAttributesUpdateRequest) StorageEntity(org.finra.herd.model.jpa.StorageEntity) StorageCreateRequest(org.finra.herd.model.api.xml.StorageCreateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 8 with StorageCreateRequest

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

Example 9 with StorageCreateRequest

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());
    }
}
Also used : 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