@Test
public void testBestPriceAlgorithmicMaxSearchPriceTooLowAndSpotPriceNotAvailable()
{

    String subnetId = SUBNET_1;
    // For master instance definition, use instance type that does not have spot price available.
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_4);
    masterInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND_LESS_ONE);
    InstanceDefinition coreInstanceDefinition = null;
    InstanceDefinition taskInstanceDefinition = null;
    // Try with master failing criteria
    try
    {
        updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
        fail();
    }
    catch (ObjectNotFoundException e)
    {
        // Set expected EMR VPC price state.
        EmrVpcPricingState expectedEmrVpcPricingState = new EmrVpcPricingState();
        expectedEmrVpcPricingState.setSubnetAvailableIpAddressCounts(new HashMap<String, Integer>()
        {{
            put(SUBNET_1, 10);
        }});
        expectedEmrVpcPricingState.setSpotPricesPerAvailabilityZone(new HashMap<String, Map<String, BigDecimal>>()
        {{
            put(AVAILABILITY_ZONE_1, new HashMap<>());
        }});
        assertEquals(String.format(
            "There were no subnets which satisfied your best price search criteria. If you explicitly opted to use spot EC2 instances, please confirm " +
                "that your instance types support spot pricing. Otherwise, try setting the max price or the on-demand threshold to a higher value.%n%s",
            emrVpcPricingStateFormatter.format(expectedEmrVpcPricingState)), e.getMessage());
    }
}