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;
}
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;
}
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);
}
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());
}
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));
}
Aggregations