Search in sources :

Example 1 with AwsRegion

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

the class AwsRegionManager method update.

@Transactional
public AwsRegion update(final Long id, final AwsRegionVO awsRegionVO) {
    final AwsRegion oldRegion = load(id);
    validateAwsRegionVO(awsRegionVO);
    final AwsRegion region = awsRegionMapper.toAwsRegion(awsRegionVO);
    region.setId(id);
    region.setOwner(oldRegion.getOwner());
    region.setCreatedDate(oldRegion.getCreatedDate());
    fillMissingRegionSettingsWithDefaultValues(region);
    switchDefaultRegion(region);
    awsRegionDao.update(region);
    return region;
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with AwsRegion

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

the class AwsRegionManager method delete.

@Transactional
public AwsRegion delete(final Long id) {
    final AwsRegion awsRegion = load(id);
    awsRegionDao.delete(id);
    return awsRegion;
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with AwsRegion

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

the class AwsRegionDaoTest method updateShouldReplaceAllEntityFields.

@Test
public void updateShouldReplaceAllEntityFields() {
    final AwsRegion originRegion = getCommonRegion();
    originRegion.setCorsRules("corsRules");
    originRegion.setPolicy("policy");
    originRegion.setKmsKeyId("kmsKeyId");
    originRegion.setKmsKeyArn("kmsKeyArn");
    originRegion.setDefault(false);
    final AwsRegion savedRegion = awsRegionDao.create(originRegion);
    final AwsRegion updatedRegion = getCommonRegion();
    updatedRegion.setId(savedRegion.getId());
    updatedRegion.setCorsRules("updatedCorsRules");
    updatedRegion.setPolicy("updatedPolicy");
    updatedRegion.setKmsKeyId("updatedKmsKeyId");
    updatedRegion.setKmsKeyArn("updatedKmsKeyArn");
    updatedRegion.setDefault(true);
    awsRegionDao.update(updatedRegion);
    final Optional<AwsRegion> actualRegionWrapper = awsRegionDao.loadById(updatedRegion.getId());
    assertTrue(actualRegionWrapper.isPresent());
    final AwsRegion actualRegion = actualRegionWrapper.get();
    assertRegionEquals(updatedRegion, actualRegion);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 4 with AwsRegion

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

the class AwsRegionDaoTest method deleteShouldRemoveEntityIfItExists.

@Test
public void deleteShouldRemoveEntityIfItExists() {
    final AwsRegion region = getCommonRegion();
    final AwsRegion createdRegion = awsRegionDao.create(region);
    awsRegionDao.delete(createdRegion.getId());
    assertFalse(awsRegionDao.loadById(createdRegion.getId()).isPresent());
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 5 with AwsRegion

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

the class AwsRegionDaoTest method createShouldThrowIfRegionIdIsNotSpecified.

@Test
public void createShouldThrowIfRegionIdIsNotSpecified() {
    final AwsRegion regionWithoutRegionId = getCommonRegion();
    regionWithoutRegionId.setAwsRegionName(null);
    assertThrows(DataIntegrityViolationException.class, () -> awsRegionDao.create(regionWithoutRegionId));
}
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