Search in sources :

Example 41 with AwsRegion

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

the class AwsRegionManagerTest method loadAllShouldReturnAllEntitiesFromDao.

@Test
public void loadAllShouldReturnAllEntitiesFromDao() {
    final AwsRegion firstRegion = getCommonRegion();
    final AwsRegion secondRegion = getCommonRegion();
    when(awsRegionDao.loadAll()).thenReturn(Arrays.asList(firstRegion, secondRegion));
    assertThat(awsRegionManager.loadAll(), containsInAnyOrder(firstRegion, secondRegion));
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) Test(org.junit.Test)

Example 42 with AwsRegion

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

the class DataStorageLoader method fetchEntity.

@Override
protected DataStorageDoc fetchEntity(final Long id) {
    AbstractDataStorage dataStorage = getApiClient().loadDataStorage(id);
    List<AwsRegion> awsRegions = getApiClient().loadAllRegions();
    DataStorageDoc.DataStorageDocBuilder docBuilder = DataStorageDoc.builder().storage(dataStorage);
    if (dataStorage instanceof S3bucketDataStorage) {
        S3bucketDataStorage bucket = (S3bucketDataStorage) dataStorage;
        docBuilder.regionName(Optional.ofNullable(bucket.getRegionId()).flatMap(regionId -> awsRegions.stream().filter(region -> region.getId().equals(bucket.getRegionId())).findFirst().map(AwsRegion::getAwsRegionName)).orElse(StringUtils.EMPTY));
    }
    return docBuilder.build();
}
Also used : AbstractCloudPipelineEntityLoader(com.epam.pipeline.elasticsearchagent.service.impl.converter.AbstractCloudPipelineEntityLoader) List(java.util.List) DataStorageDoc(com.epam.pipeline.elasticsearchagent.model.DataStorageDoc) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.S3bucketDataStorage) CloudPipelineAPIClient(com.epam.pipeline.elasticsearchagent.service.impl.CloudPipelineAPIClient) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Optional(java.util.Optional) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) AwsRegion(com.epam.pipeline.entity.region.AwsRegion) StringUtils(org.apache.commons.lang3.StringUtils) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) AwsRegion(com.epam.pipeline.entity.region.AwsRegion) DataStorageDoc(com.epam.pipeline.elasticsearchagent.model.DataStorageDoc) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.S3bucketDataStorage)

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