use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetKmsKeyIdToDefaultValueIfMissing.
@Test
public void createShouldSetKmsKeyIdToDefaultValueIfMissing() {
final String defaultKeyId = KMS_KEY_ID;
when(preferenceManager.getPreference(SystemPreferences.DATA_STORAGE_SECURITY_KEY_ID)).thenReturn(defaultKeyId);
final AwsRegionVO regionVO = getAwsRegionVoBuilder().kmsKeyArn(KMS_KEY_ARN).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.getKmsKeyId(), is(defaultKeyId));
}
use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManager method changeOwner.
@Override
public AwsRegion changeOwner(final Long id, final String owner) {
final AwsRegion awsRegion = load(id);
awsRegion.setOwner(owner);
final AwsRegionVO awsRegionVO = awsRegionMapper.toAwsRegionVO(awsRegion);
return update(id, awsRegionVO);
}
use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetOwnerForAwsRegion.
@Test
public void createShouldSetOwnerForAwsRegion() {
final String ownerUserName = "ownerUserName";
final AwsRegionVO awsRegionVO = getAwsRegionVoBuilder().build();
when(authManager.getAuthorizedUser()).thenReturn(ownerUserName);
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();
assertThat(actualRegion.getOwner(), is(ownerUserName));
}
use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method updateShouldUpdateEntityInDao.
@Test
public void updateShouldUpdateEntityInDao() {
final AwsRegion originalRegion = getCommonRegion();
originalRegion.setId(ID);
originalRegion.setCorsRules(EMPTY_CORS_RULES);
originalRegion.setPolicy(EMPTY_POLICY);
originalRegion.setKmsKeyId(KMS_KEY_ID);
originalRegion.setKmsKeyArn(KMS_KEY_ARN);
final AwsRegion updatedRegion = getCommonRegion();
updatedRegion.setId(ID);
updatedRegion.setName("anotherName");
updatedRegion.setCorsRules(EMPTY_CORS_RULES);
updatedRegion.setPolicy(EMPTY_POLICY);
updatedRegion.setKmsKeyId(KMS_KEY_ID);
updatedRegion.setKmsKeyArn(KMS_KEY_ARN);
final AwsRegionVO updatedRegionVO = awsRegionMapper.toAwsRegionVO(updatedRegion);
when(awsRegionDao.loadById(ID)).thenReturn(Optional.of(originalRegion));
awsRegionManager.update(ID, updatedRegionVO);
verify(awsRegionDao).update(eq(updatedRegion));
}
use of com.epam.pipeline.controller.vo.AwsRegionVO in project cloud-pipeline by epam.
the class AwsRegionManagerTest method createShouldSetPolicyToNullIfDefaultValueIsNull.
@Test
public void createShouldSetPolicyToNullIfDefaultValueIsNull() {
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().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(), isEmptyOrNullString());
}
Aggregations