use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method loadByIdShouldRetrieveRegionFromDao.
@Test
public void loadByIdShouldRetrieveRegionFromDao() {
final AwsRegion expectedRegion = getCommonRegion();
when(awsRegionDao.loadById(eq(ID))).thenReturn(Optional.of(expectedRegion));
final AwsRegion actualRegion = awsRegionManager.load(ID);
assertRegionEquals(expectedRegion, actualRegion);
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method updateShouldSaveCreatedDateFromTheOldValue.
@Test
public void updateShouldSaveCreatedDateFromTheOldValue() {
final Date createdDate = new Date();
final AwsRegionVO awsRegionVO = getAwsRegionVoBuilder().build();
final AwsRegion originalRegion = getCommonRegion();
originalRegion.setCreatedDate(createdDate);
when(awsRegionDao.loadById(ID)).thenReturn(Optional.of(originalRegion));
doReturn(Optional.ofNullable(null)).when(preferenceManager).load(SystemPreferences.DATA_STORAGE_CORS_POLICY.getKey());
doReturn(Optional.ofNullable(null)).when(preferenceManager).load(SystemPreferences.DATA_STORAGE_POLICY.getKey());
awsRegionManager.update(ID, awsRegionVO);
final ArgumentCaptor<AwsRegion> regionCaptor = ArgumentCaptor.forClass(AwsRegion.class);
verify(awsRegionDao).update(regionCaptor.capture());
final AwsRegion actualRegion = regionCaptor.getValue();
assertThat(actualRegion.getCreatedDate(), is(createdDate));
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method getCommonRegion.
private AwsRegion getCommonRegion() {
final AwsRegion awsRegion = new AwsRegion();
awsRegion.setName(REGION_NAME);
awsRegion.setAwsRegionName(VALID_REGION_ID);
awsRegion.setOwner("owner");
awsRegion.setCreatedDate(new Date());
return awsRegion;
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method deleteShouldRemoveEntityFromDao.
@Test
public void deleteShouldRemoveEntityFromDao() {
final AwsRegion awsRegion = getCommonRegion();
when(awsRegionDao.loadById(ID)).thenReturn(Optional.of(awsRegion));
awsRegionManager.delete(ID);
verify(awsRegionDao).delete(ID);
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetCorsRulesToNullIfDefaultValueIsNull.
@Test
public void createShouldSetCorsRulesToNullIfDefaultValueIsNull() {
doReturn(Optional.ofNullable(null)).when(preferenceManager).load(SystemPreferences.DATA_STORAGE_CORS_POLICY.getKey());
doReturn(Optional.ofNullable(null)).when(preferenceManager).load(SystemPreferences.DATA_STORAGE_POLICY.getKey());
final AwsRegionVO regionVO = getAwsRegionVoBuilder().policy(EMPTY_POLICY).kmsKeyId(KMS_KEY_ID).kmsKeyArn(KMS_KEY_ARN).awsRegionName(VALID_REGION_ID).isDefault(false).build();
awsRegionManager.create(regionVO);
final ArgumentCaptor<AwsRegion> regionCaptor = ArgumentCaptor.forClass(AwsRegion.class);
verify(awsRegionDao).create(regionCaptor.capture());
final AwsRegion actualRegion = regionCaptor.getValue();
assertThat(actualRegion.getCorsRules(), isEmptyOrNullString());
}
Aggregations