use of org.finra.herd.dao.impl.MockSpotPrice 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