Search in sources :

Example 1 with InstanceTypeOffering

use of com.amazonaws.services.ec2.model.InstanceTypeOffering in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method setUp.

@BeforeEach
public void setUp() {
    AvailabilityZone availabilityZone = new AvailabilityZone();
    availabilityZone.setZoneName(AZ_NAME);
    Region awsRegion = new Region();
    awsRegion.setRegionName(REGION_NAME);
    InstanceTypeOffering instanceTypeOffering = new InstanceTypeOffering();
    instanceTypeOffering.setInstanceType("m5.2xlarge");
    instanceTypeInfos = new ArrayList<>();
    instanceTypeInfos.add(getInstanceTypeInfo("m5.2xlarge"));
    describeInstanceTypesResult.setInstanceTypes(instanceTypeInfos);
    when(awsDefaultZoneProvider.getDefaultZone(any(CloudCredential.class))).thenReturn(REGION_NAME);
    when(awsClient.createEc2Client(any(AwsCredentialView.class))).thenReturn(amazonEC2Client);
    when(awsClient.createEc2Client(any(AwsCredentialView.class), any())).thenReturn(amazonEC2Client);
    when(amazonEC2Client.describeRegions(any(DescribeRegionsRequest.class))).thenReturn(describeRegionsResult);
    when(describeRegionsResult.getRegions()).thenReturn(Collections.singletonList(awsRegion));
    when(awsAvailabilityZoneProvider.describeAvailabilityZones(any(), any(), any())).thenReturn(List.of(availabilityZone));
    when(amazonEC2Client.describeInstanceTypeOfferings(any(DescribeInstanceTypeOfferingsRequest.class))).thenReturn(describeInstanceTypeOfferingsResult);
    when(amazonEC2Client.describeInstanceTypes(any(DescribeInstanceTypesRequest.class))).thenReturn(describeInstanceTypesResult);
    when(describeInstanceTypesResult.getInstanceTypes()).thenReturn(instanceTypeInfos);
    when(describeInstanceTypeOfferingsResult.getInstanceTypeOfferings()).thenReturn(Collections.singletonList(instanceTypeOffering));
    ReflectionTestUtils.setField(underTest, "fetchMaxItems", 500);
    region = region(REGION_NAME);
    ReflectionTestUtils.setField(underTest, "enabledRegions", Set.of(region));
    ReflectionTestUtils.setField(underTest, "enabledAvailabilityZones", Set.of(availabilityZone(AZ_NAME)));
    cloudCredential = new ExtendedCloudCredential(new CloudCredential("crn", "aws-credential", "account"), "AWS", null, "crn", "id", new ArrayList<>());
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) DescribeInstanceTypesRequest(com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) InstanceTypeOffering(com.amazonaws.services.ec2.model.InstanceTypeOffering) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) DescribeInstanceTypeOfferingsRequest(com.amazonaws.services.ec2.model.DescribeInstanceTypeOfferingsRequest) ArrayList(java.util.ArrayList) AvailabilityZone(com.amazonaws.services.ec2.model.AvailabilityZone) Region(com.amazonaws.services.ec2.model.Region) DescribeRegionsRequest(com.amazonaws.services.ec2.model.DescribeRegionsRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

AvailabilityZone (com.amazonaws.services.ec2.model.AvailabilityZone)1 DescribeInstanceTypeOfferingsRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypeOfferingsRequest)1 DescribeInstanceTypesRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest)1 DescribeRegionsRequest (com.amazonaws.services.ec2.model.DescribeRegionsRequest)1 InstanceTypeOffering (com.amazonaws.services.ec2.model.InstanceTypeOffering)1 Region (com.amazonaws.services.ec2.model.Region)1 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 ArrayList (java.util.ArrayList)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1