@Test
public void testUpdateEmrClusterDefinitionWithNonValidInstanceFleetSubnets()
{

    // Create an AWS params DTO
    AwsParamsDto awsParamsDto = new AwsParamsDto();
    // Create an EMR cluster alternate key DTO
    EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME);
    // Create an EMR cluster definition object
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    emrClusterDefinition.setInstanceFleetMinimumIpAvailableFilter(50);
    // Create subnet object
    List<Subnet> subnets = initializeTestSubnets(3);
    // Mock the external calls.
    when(emrPricingHelper.getSubnets(emrClusterDefinition, awsParamsDto)).thenReturn(subnets);
    when(jsonHelper.objectToJson(Mockito.any())).thenReturn("{jsonFormattedSubnetsAvailability}");
    // Call the method under test.
    try
    {
        emrHelperServiceImpl.updateEmrClusterDefinitionWithValidInstanceFleetSubnets(emrClusterAlternateKeyDto, emrClusterDefinition, awsParamsDto);
        fail("IllegalArgumentException expected");
    }
    catch (IllegalArgumentException ex)
    {
        assertTrue(ex.getMessage().startsWith("Specified subnets do not have enough available IP addresses required for the instance fleet."));
        assertTrue(ex.getMessage().contains(NAMESPACE));
        assertTrue(ex.getMessage().contains(EMR_CLUSTER_DEFINITION_NAME));
        assertTrue(ex.getMessage().contains(EMR_CLUSTER_NAME));
        assertTrue(ex.getMessage().contains("{jsonFormattedSubnetsAvailability}"));
    }
    // Verify the external calls.
    verify(emrPricingHelper).getSubnets(emrClusterDefinition, awsParamsDto);
    verify(jsonHelper).objectToJson(Mockito.any());
    verifyNoMoreInteractionsHelper();
}