use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetCreatedDateForAwsRegion.
@Test
public void createShouldSetCreatedDateForAwsRegion() {
final AwsRegionVO awsRegionVO = getAwsRegionVoBuilder().build();
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.create(awsRegionVO);
final ArgumentCaptor<AwsRegion> regionCaptor = ArgumentCaptor.forClass(AwsRegion.class);
verify(awsRegionDao).create(regionCaptor.capture());
final AwsRegion actualRegion = regionCaptor.getValue();
assertNotNull(actualRegion.getCreatedDate());
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetPolicyToDefaultValueIfMissing.
@Test
public void createShouldSetPolicyToDefaultValueIfMissing() {
final String defaultPolicyAsString = "{" + "\"key1\":\"value1\"," + "\"key2\":\"value2\"" + "}";
Preference policy = new Preference();
policy.setValue(defaultPolicyAsString);
doReturn(Optional.of(policy)).when(preferenceManager).load(SystemPreferences.DATA_STORAGE_POLICY.getKey());
final AwsRegionVO regionVO = getAwsRegionVoBuilder().corsRules(EMPTY_CORS_RULES).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.getPolicy(), is(defaultPolicyAsString));
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSaveRegionAsIsIfAllOptionalFieldsIsAlreadySet.
@Test
public void createShouldSaveRegionAsIsIfAllOptionalFieldsIsAlreadySet() {
final AwsRegionVO regionVO = getAwsRegionVoBuilder().corsRules(EMPTY_CORS_RULES).policy(EMPTY_POLICY).kmsKeyId(KMS_KEY_ID).kmsKeyArn(KMS_KEY_ARN).awsRegionName(VALID_REGION_ID).isDefault(false).build();
final AwsRegion expectedRegion = awsRegionMapper.toAwsRegion(regionVO);
awsRegionManager.create(regionVO);
final ArgumentCaptor<AwsRegion> regionCaptor = ArgumentCaptor.forClass(AwsRegion.class);
verify(awsRegionDao).create(regionCaptor.capture());
final AwsRegion actualRegion = regionCaptor.getValue();
assertRegionEquals(expectedRegion, actualRegion);
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetKmsKeyArnToDefaultValueIfMissing.
@Test
public void createShouldSetKmsKeyArnToDefaultValueIfMissing() {
final String defaultKeyArn = KMS_KEY_ARN;
when(preferenceManager.getPreference(SystemPreferences.DATA_STORAGE_SECURITY_KEY_ARN)).thenReturn(defaultKeyArn);
final AwsRegionVO regionVO = getAwsRegionVoBuilder().kmsKeyId(KMS_KEY_ID).policy(EMPTY_POLICY).corsRules(EMPTY_CORS_RULES).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.getKmsKeyArn(), is(defaultKeyArn));
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionManagerTest method updateShouldSaveOwnerFromTheOldValue.
@Test
public void updateShouldSaveOwnerFromTheOldValue() {
final String ownerUserName = "ownerUserName";
final AwsRegionVO awsRegionVO = getAwsRegionVoBuilder().build();
final AwsRegion originalRegion = getCommonRegion();
originalRegion.setOwner(ownerUserName);
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.getOwner(), is(ownerUserName));
}
Aggregations