use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class AwsRegionDaoTest method loadAllShouldReturnListWithAllCreatedEntities.
@Test
public void loadAllShouldReturnListWithAllCreatedEntities() {
final AwsRegion firstRegion = awsRegionDao.create(getCommonRegion());
final AwsRegion secondRegion = awsRegionDao.create(getCommonRegion());
final List<AwsRegion> actualAwsRegions = awsRegionDao.loadAll();
assertThat(actualAwsRegions, containsInAnyOrder(firstRegion, secondRegion));
}
use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.
the class FolderTemplateManagerTest method setUp.
@Before
public void setUp() throws Exception {
doReturn(new MockS3Helper()).when(storageProviderManager).getS3Helper(any());
awsRegion = new AwsRegion();
awsRegion.setName("US");
awsRegion.setAwsRegionName("us-east-1");
awsRegion.setDefault(true);
awsRegionDao.create(awsRegion);
AclTestDao.AclSid testUserSid = new AclTestDao.AclSid(true, TEST_USER);
aclTestDao.createAclSid(testUserSid);
AclTestDao.AclSid testRole = new AclTestDao.AclSid(false, TEST_ROLE);
aclTestDao.createAclSid(testRole);
AclTestDao.AclClass folderAclClass = new AclTestDao.AclClass(Folder.class.getCanonicalName());
aclTestDao.createAclClassIfNotPresent(folderAclClass);
}
use of com.epam.pipeline.entity.region.AwsRegion 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.entity.region.AwsRegion 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.entity.region.AwsRegion 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