Search in sources :

Example 31 with AwsRegion

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));
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Example 32 with AwsRegion

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);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) AclTestDao(com.epam.pipeline.dao.util.AclTestDao) Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) MockS3Helper(com.epam.pipeline.manager.MockS3Helper) Before(org.junit.Before)

Example 33 with AwsRegion

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));
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO) Test(org.junit.Test)

Example 34 with AwsRegion

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));
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO) Test(org.junit.Test)

Example 35 with AwsRegion

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());
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO) Test(org.junit.Test)

Aggregations

AwsRegion (com.epam.pipeline.entity.region.AwsRegion)42 Test (org.junit.Test)24 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)13 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)6 Transactional (org.springframework.transaction.annotation.Transactional)5 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)4 Before (org.junit.Before)4 Date (java.util.Date)3 List (java.util.List)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2 MessageHelper (com.epam.pipeline.common.MessageHelper)2 InstancePrice (com.epam.pipeline.entity.cluster.InstancePrice)2 PipelineRunPrice (com.epam.pipeline.entity.cluster.PipelineRunPrice)2 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)2 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)2 DataStorageException (com.epam.pipeline.entity.datastorage.DataStorageException)2 StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)2 S3bucketDataStorage (com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)2 Folder (com.epam.pipeline.entity.pipeline.Folder)2