use of org.finra.herd.dao.impl.Ec2DaoImpl in project herd by FINRAOS.
the class Ec2DaoTest method testGetLatestSpotPricesAssertConstructsCorrectDescribeSpotPriceHistoryRequest.
@Test
public void testGetLatestSpotPricesAssertConstructsCorrectDescribeSpotPriceHistoryRequest() {
// Initialize inputs.
String availabilityZone = "a";
Collection<String> instanceTypes = Arrays.asList("a", "b", "c");
Collection<String> productDescriptions = Arrays.asList("b", "c", "d");
// Set up mock.
mock(RetryPolicyFactory.class);
Ec2Operations ec2Operations = mock(Ec2Operations.class);
((Ec2DaoImpl) ec2Dao).setEc2Operations(ec2Operations);
DescribeSpotPriceHistoryResult describeSpotPriceHistoryResult = new DescribeSpotPriceHistoryResult();
when(ec2Operations.describeSpotPriceHistory(any(), any())).thenReturn(describeSpotPriceHistoryResult);
// Execute MUT.
ec2Dao.getLatestSpotPrices(availabilityZone, instanceTypes, productDescriptions, new AwsParamsDto());
// Verify that the dependency was called with the correct parameters.
verify(ec2Operations).describeSpotPriceHistory(any(), equalsDescribeSpotPriceHistoryRequest(availabilityZone, instanceTypes, productDescriptions));
}
use of org.finra.herd.dao.impl.Ec2DaoImpl in project herd by FINRAOS.
the class Ec2DaoTest method testGetLatestSpotPricesSpotPriceHistoryContainDuplicateTypeInstances.
@Test
public void testGetLatestSpotPricesSpotPriceHistoryContainDuplicateTypeInstances() {
// Initialize inputs.
Collection<String> instanceTypes = Arrays.asList(MockEc2OperationsImpl.INSTANCE_TYPE_1, MockEc2OperationsImpl.INSTANCE_TYPE_2);
Collection<String> productDescriptions = Arrays.asList("b", "c");
// Set up mock.
mock(RetryPolicyFactory.class);
Ec2Operations ec2Operations = mock(Ec2Operations.class);
((Ec2DaoImpl) ec2Dao).setEc2Operations(ec2Operations);
DescribeSpotPriceHistoryResult describeSpotPriceHistoryResult = new DescribeSpotPriceHistoryResult();
List<SpotPrice> spotPrices = new ArrayList<>();
spotPrices.add(new MockSpotPrice(MockEc2OperationsImpl.INSTANCE_TYPE_1, MockEc2OperationsImpl.AVAILABILITY_ZONE_1, MockEc2OperationsImpl.SPOT_PRICE_HIGH).toAwsObject());
spotPrices.add(new MockSpotPrice(MockEc2OperationsImpl.INSTANCE_TYPE_1, MockEc2OperationsImpl.AVAILABILITY_ZONE_2, MockEc2OperationsImpl.SPOT_PRICE_HIGH).toAwsObject());
describeSpotPriceHistoryResult.setSpotPriceHistory(spotPrices);
when(ec2Operations.describeSpotPriceHistory(any(), any())).thenReturn(describeSpotPriceHistoryResult);
// Execute MUT.
List<SpotPrice> result = ec2Dao.getLatestSpotPrices(MockEc2OperationsImpl.AVAILABILITY_ZONE_1, instanceTypes, productDescriptions, new AwsParamsDto());
// Verify that the dependency was called with the correct parameters.
verify(ec2Operations).describeSpotPriceHistory(any(), equalsDescribeSpotPriceHistoryRequest(MockEc2OperationsImpl.AVAILABILITY_ZONE_1, instanceTypes, productDescriptions));
// Verify that result contains only one spot price entry.
assertEquals(1, CollectionUtils.size(result));
}
Aggregations