use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldThrowIfSpecifiedPolicyIsInvalid.
@Test
public void createShouldThrowIfSpecifiedPolicyIsInvalid() {
final AwsRegionVO awsRegionVO = getAwsRegionVoBuilder().policy(INVALID_POLICY).build();
assertThrows(AwsRegionException.class, () -> awsRegionManager.create(awsRegionVO));
}
use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetCorsRulesToDefaultValueIfMissing.
@Test
public void createShouldSetCorsRulesToDefaultValueIfMissing() {
final String corsRulesAsString = "[{" + "\"id\":\"id1\"," + "\"allowedOrigins\":[\"origin1\",\"origin2\"]," + "\"maxAgeSeconds\":0" + "},{" + "\"id\":\"id2\"," + "\"maxAgeSeconds\":0," + "\"allowedHeaders\":[\"header1\"]" + "}]";
Preference corsPolicy = new Preference();
corsPolicy.setValue(corsRulesAsString);
doReturn(Optional.of(corsPolicy)).when(preferenceManager).load(eq(SystemPreferences.DATA_STORAGE_CORS_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(), is(corsRulesAsString));
}
use of com.epam.pipeline.controller.vo.AwsRegionVO 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.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSaveEntityInDao.
@Test
public void createShouldSaveEntityInDao() {
final AwsRegionVO regionVO = getAwsRegionVoBuilder().awsRegionName(VALID_REGION_ID).corsRules(EMPTY_CORS_RULES).policy(EMPTY_POLICY).kmsKeyId(KMS_KEY_ID).kmsKeyArn(KMS_KEY_ARN).isDefault(false).build();
awsRegionManager.create(regionVO);
verify(awsRegionDao).create(any());
}
use of com.epam.pipeline.controller.vo.AwsRegionVO 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