Search in sources :

Example 11 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class FolderDaoTest method addStorage.

private AbstractDataStorage addStorage(Folder folder) {
    // add datastorage
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(TEST_DATASTORAGE, TEST_DATASTORAGE, DataStorageType.S3, S3_TEST_DATASTORAGE_PATH, 1, 1, folder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage storage = storageFactory.convertToDataStorage(storageVO);
    storage.setOwner(TEST_USER);
    dataStorageDao.createDataStorage(storage);
    return storage;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO)

Example 12 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageManagerTest method testFailToGenerateSharedURLForNotSharedStorage.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailToGenerateSharedURLForNotSharedStorage() {
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, WITHOUT_PARENT_ID, TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    storageManager.generateSharedUrlForStorage(saved.getId());
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageManagerTest method testGenerateSharedURLForSharedStorage.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testGenerateSharedURLForSharedStorage() {
    Preference preference = SystemPreferences.BASE_API_SHARED.toPreference();
    preference.setValue(SHARED_BASE_URL_TEMPLATE);
    preferenceManager.update(Collections.singletonList(preference));
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, WITHOUT_PARENT_ID, TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    storageVO.setShared(true);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    String url = storageManager.generateSharedUrlForStorage(saved.getId());
    Assert.assertEquals(SHARED_BASE_URL + saved.getId(), url);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Preference(com.epam.pipeline.entity.preference.Preference) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageManagerTest method saveDataStorageTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void saveDataStorageTest() throws Exception {
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, WITHOUT_PARENT_ID, TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    AbstractDataStorage loaded = storageManager.load(saved.getId());
    compareDataStorage(saved, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with AbstractDataStorage

use of com.epam.pipeline.entity.datastorage.AbstractDataStorage in project cloud-pipeline by epam.

the class DataStorageManagerTest method updateDataStorageTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void updateDataStorageTest() throws Exception {
    Folder folder = new Folder();
    folder.setName("testfolder");
    folderManager.create(folder);
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, folder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    Folder newFolder = new Folder();
    newFolder.setName("newtestfolder");
    folderManager.create(newFolder);
    // test that we can change parent folder for storage
    storageVO.setId(saved.getId());
    storageVO.setParentFolderId(newFolder.getId());
    storageManager.update(storageVO);
    AbstractDataStorage loaded = storageManager.load(saved.getId());
    assertDataStorageAccordingToUpdateStorageVO(storageVO, loaded);
    // test that we can change description for storage
    storageVO.setDescription(CHANGED);
    storageManager.update(storageVO);
    loaded = storageManager.load(saved.getId());
    assertDataStorageAccordingToUpdateStorageVO(storageVO, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)62 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)22 Test (org.junit.Test)22 Transactional (org.springframework.transaction.annotation.Transactional)18 Folder (com.epam.pipeline.entity.pipeline.Folder)13 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)11 ArrayList (java.util.ArrayList)7 List (java.util.List)6 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)5 Service (org.springframework.stereotype.Service)5 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)4 UpdateDataStorageItemVO (com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO)3 DataStorageDownloadFileUrl (com.epam.pipeline.entity.datastorage.DataStorageDownloadFileUrl)3 DataStorageException (com.epam.pipeline.entity.datastorage.DataStorageException)3 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)3 DataStorageLink (com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)3 ObjectCreatorUtils.constructDataStorageVO (com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO)3 IOException (java.io.IOException)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2