Search in sources :

Example 16 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionManagerTest method loadByIdShouldRetrieveRegionFromDao.

@Test
public void loadByIdShouldRetrieveRegionFromDao() {
    final AwsRegion expectedRegion = getCommonRegion();
    when(awsRegionDao.loadById(eq(ID))).thenReturn(Optional.of(expectedRegion));
    final AwsRegion actualRegion = awsRegionManager.load(ID);
    assertRegionEquals(expectedRegion, actualRegion);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test)

Example 17 with AwsRegion

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

Example 18 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionManagerTest method getCommonRegion.

private AwsRegion getCommonRegion() {
    final AwsRegion awsRegion = new AwsRegion();
    awsRegion.setName(REGION_NAME);
    awsRegion.setAwsRegionName(VALID_REGION_ID);
    awsRegion.setOwner("owner");
    awsRegion.setCreatedDate(new Date());
    return awsRegion;
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Date(java.util.Date)

Example 19 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion in project cloud-pipeline by epam.

the class AwsRegionManagerTest method deleteShouldRemoveEntityFromDao.

@Test
public void deleteShouldRemoveEntityFromDao() {
    final AwsRegion awsRegion = getCommonRegion();
    when(awsRegionDao.loadById(ID)).thenReturn(Optional.of(awsRegion));
    awsRegionManager.delete(ID);
    verify(awsRegionDao).delete(ID);
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test)

Example 20 with AwsRegion

use of com.epam.pipeline.entity.region.AwsRegion 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());
}
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