Search in sources :

Example 26 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionManager method create.

@Transactional
public AwsRegion create(final AwsRegionVO awsRegionVO) {
    validateAwsRegionVO(awsRegionVO);
    final AwsRegion region = awsRegionMapper.toAwsRegion(awsRegionVO);
    region.setOwner(authManager.getAuthorizedUser());
    region.setCreatedDate(DateUtils.now());
    fillMissingRegionSettingsWithDefaultValues(region);
    switchDefaultRegion(region);
    return awsRegionDao.create(region);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionManager method changeOwner.

@Override
public AwsRegion changeOwner(final Long id, final String owner) {
    final AwsRegion awsRegion = load(id);
    awsRegion.setOwner(owner);
    final AwsRegionVO awsRegionVO = awsRegionMapper.toAwsRegionVO(awsRegion);
    return update(id, awsRegionVO);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO)

Example 28 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class DataStorageDaoTest method setUp.

@Before
public void setUp() {
    testFolder = buildFolder(null);
    awsRegion = new AwsRegion();
    awsRegion.setName("Default");
    awsRegion.setDefault(true);
    awsRegion.setAwsRegionName("us-east-1");
    awsRegionDao.create(awsRegion);
    s3Bucket = new S3bucketDataStorage(null, TEST_STORAGE_NAME, TEST_STORAGE_PATH);
    s3Bucket.setDescription("testDescription");
    s3Bucket.setParentFolderId(testFolder.getId());
    s3Bucket.setRegionId(awsRegion.getId());
    s3Bucket.setOwner(TEST_OWNER);
    s3Bucket.setMountPoint("testMountPoint");
    s3Bucket.setMountOptions("testMountOptions");
    s3Bucket.setShared(true);
    s3Bucket.setAllowedCidrs(Arrays.asList("test1", "test2"));
    policy = new StoragePolicy();
    policy.setBackupDuration(BACKUP_DURATION);
    policy.setLongTermStorageDuration(LTS_DURATION);
    policy.setShortTermStorageDuration(STS_DURATION);
    policy.setVersioningEnabled(true);
    s3Bucket.setStoragePolicy(policy);
    nfsStorage = new NFSDataStorage(null, "NFS_STORAGE", "nfs_path");
    nfsStorage.setOwner(TEST_OWNER);
    nfsStorage.setDescription("NFS");
    nfsStorage.setParentFolderId(testFolder.getId());
    nfsStorage.setMountOptions("-s");
    nfsStorage.setMountPoint("nfs");
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Before(org.junit.Before)

Example 29 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionDaoTest method loadByIdShouldReturnEntityWithTheGivenId.

@Test
public void loadByIdShouldReturnEntityWithTheGivenId() {
    final AwsRegion expectedRegion = awsRegionDao.create(getCommonRegion());
    final Optional<AwsRegion> actualRegionWrapper = awsRegionDao.loadById(expectedRegion.getId());
    assertTrue(actualRegionWrapper.isPresent());
    final AwsRegion actualRegion = actualRegionWrapper.get();
    assertThat(actualRegion.getId(), is(expectedRegion.getId()));
    assertRegionEquals(expectedRegion, actualRegion);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 30 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionDaoTest method createShouldThrowIfNameIsNotSpecified.

@Test
public void createShouldThrowIfNameIsNotSpecified() {
    final AwsRegion regionWithoutName = getCommonRegion();
    regionWithoutName.setName(null);
    assertThrows(DataIntegrityViolationException.class, () -> awsRegionDao.create(regionWithoutName));
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Aggregations

AwsRegion (com.epam.pipeline.entity.region.AwsRegion)42 Test (org.junit.Test)24 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)13 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)6 Transactional (org.springframework.transaction.annotation.Transactional)5 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)4 Before (org.junit.Before)4 Date (java.util.Date)3 List (java.util.List)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2 MessageHelper (com.epam.pipeline.common.MessageHelper)2 InstancePrice (com.epam.pipeline.entity.cluster.InstancePrice)2 PipelineRunPrice (com.epam.pipeline.entity.cluster.PipelineRunPrice)2 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)2 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)2 DataStorageException (com.epam.pipeline.entity.datastorage.DataStorageException)2 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)2 S3bucketDataStorage (com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)2 Folder (com.epam.pipeline.entity.pipeline.Folder)2