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));
}
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();
}
Aggregations