@Test
public void testBestPricePickMultipleInstancesSelectCheaperCoreAndTask()
{

    String subnetId = SUBNET_1 + "," + SUBNET_4;
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_2);
    masterInstanceDefinition.setInstanceSpotPrice(SPOT_PRICE_VERY_HIGH);
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
    coreInstanceDefinition.setInstanceCount(2);
    coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    coreInstanceDefinition.setInstanceSpotPrice(ON_DEMAND);
    InstanceDefinition taskInstanceDefinition = new InstanceDefinition();
    taskInstanceDefinition.setInstanceCount(3);
    taskInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    taskInstanceDefinition.setInstanceSpotPrice(ON_DEMAND);
    EmrClusterDefinition emrClusterDefinition =
        updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
    assertBestPriceCriteriaRemoved(emrClusterDefinition);
    assertEquals("master instance bid price", SPOT_PRICE_VERY_HIGH,
        emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
    assertEquals("core instance bid price", ON_DEMAND, emrClusterDefinition.getInstanceDefinitions().getCoreInstances().getInstanceSpotPrice());
    assertEquals("task instance bid price", ON_DEMAND, emrClusterDefinition.getInstanceDefinitions().getTaskInstances().getInstanceSpotPrice());
    assertEquals("selected subnet", SUBNET_4, emrClusterDefinition.getSubnetId());
}