test_class.declarator: awsServiceHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private AwsServiceHelper awsServiceHelper;
test_class.type: AwsServiceHelper
test_class.var_name: awsServiceHelper
test_class.declarator: configurationHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ConfigurationHelper configurationHelper;
test_class.type: ConfigurationHelper
test_class.var_name: configurationHelper
test_class.declarator: emrClusterDefinitionDaoHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private EmrClusterDefinitionDaoHelper emrClusterDefinitionDaoHelper;
test_class.type: EmrClusterDefinitionDaoHelper
test_class.var_name: emrClusterDefinitionDaoHelper
test_class.declarator: emrClusterDefinitionHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private EmrClusterDefinitionHelper emrClusterDefinitionHelper;
test_class.type: EmrClusterDefinitionHelper
test_class.var_name: emrClusterDefinitionHelper
test_class.declarator: emrDao
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private EmrDao emrDao;
test_class.type: EmrDao
test_class.var_name: emrDao
test_class.declarator: emrHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private EmrHelper emrHelper;
test_class.type: EmrHelper
test_class.var_name: emrHelper
test_class.declarator: emrHelperServiceImpl
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private EmrHelperServiceImpl emrHelperServiceImpl;
test_class.type: EmrHelperServiceImpl
test_class.var_name: emrHelperServiceImpl
test_class.declarator: emrPricingHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private EmrPricingHelper emrPricingHelper;
test_class.type: EmrPricingHelper
test_class.var_name: emrPricingHelper
test_class.declarator: herdDao
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private HerdDao herdDao;
test_class.type: HerdDao
test_class.var_name: herdDao
test_class.declarator: namespaceDaoHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private NamespaceDaoHelper namespaceDaoHelper;
test_class.type: NamespaceDaoHelper
test_class.var_name: namespaceDaoHelper
test_class.declarator: namespaceIamRoleAuthorizationHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private NamespaceIamRoleAuthorizationHelper namespaceIamRoleAuthorizationHelper;
test_class.type: NamespaceIamRoleAuthorizationHelper
test_class.var_name: namespaceIamRoleAuthorizationHelper
test_class.declarator: xmlHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private XmlHelper xmlHelper;
test_class.type: XmlHelper
test_class.var_name: xmlHelper
test_class.declarator: jsonHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private JsonHelper jsonHelper;
test_class.type: JsonHelper
test_class.var_name: jsonHelper
test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/impl/EmrHelperServiceImplTest.java
test_class.identifier: EmrHelperServiceImplTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @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();
  
      }
test_case.class_method_signature: EmrHelperServiceImplTest.testUpdateEmrClusterDefinitionWithNonValidInstanceFleetSubnets()
test_case.full_signature: @Test public void testUpdateEmrClusterDefinitionWithNonValidInstanceFleetSubnets()
test_case.identifier: testUpdateEmrClusterDefinitionWithNonValidInstanceFleetSubnets
test_case.invocations: setInstanceFleetMinimumIpAvailableFilter initializeTestSubnets thenReturn when getSubnets thenReturn when objectToJson any updateEmrClusterDefinitionWithValidInstanceFleetSubnets fail assertTrue startsWith getMessage assertTrue contains getMessage assertTrue contains getMessage assertTrue contains getMessage assertTrue contains getMessage getSubnets verify objectToJson verify any verifyNoMoreInteractionsHelper
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUpdateEmrClusterDefinitionWithNonValidInstanceFleetSubnets()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(EmrHelperServiceImpl.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(EmrHelperServiceImpl.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: awsServiceHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private AwsServiceHelper awsServiceHelper;
focal_class.type: AwsServiceHelper
focal_class.var_name: awsServiceHelper
focal_class.declarator: configurationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ConfigurationHelper configurationHelper;
focal_class.type: ConfigurationHelper
focal_class.var_name: configurationHelper
focal_class.declarator: emrClusterDefinitionDaoHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EmrClusterDefinitionDaoHelper emrClusterDefinitionDaoHelper;
focal_class.type: EmrClusterDefinitionDaoHelper
focal_class.var_name: emrClusterDefinitionDaoHelper
focal_class.declarator: emrClusterDefinitionHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EmrClusterDefinitionHelper emrClusterDefinitionHelper;
focal_class.type: EmrClusterDefinitionHelper
focal_class.var_name: emrClusterDefinitionHelper
focal_class.declarator: emrDao
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EmrDao emrDao;
focal_class.type: EmrDao
focal_class.var_name: emrDao
focal_class.declarator: emrHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EmrHelper emrHelper;
focal_class.type: EmrHelper
focal_class.var_name: emrHelper
focal_class.declarator: emrPricingHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EmrPricingHelper emrPricingHelper;
focal_class.type: EmrPricingHelper
focal_class.var_name: emrPricingHelper
focal_class.declarator: herdDao
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private HerdDao herdDao;
focal_class.type: HerdDao
focal_class.var_name: herdDao
focal_class.declarator: jsonHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private JsonHelper jsonHelper;
focal_class.type: JsonHelper
focal_class.var_name: jsonHelper
focal_class.declarator: namespaceDaoHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private NamespaceDaoHelper namespaceDaoHelper;
focal_class.type: NamespaceDaoHelper
focal_class.var_name: namespaceDaoHelper
focal_class.declarator: namespaceIamRoleAuthorizationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private NamespaceIamRoleAuthorizationHelper namespaceIamRoleAuthorizationHelper;
focal_class.type: NamespaceIamRoleAuthorizationHelper
focal_class.var_name: namespaceIamRoleAuthorizationHelper
focal_class.declarator: xmlHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private XmlHelper xmlHelper;
focal_class.type: XmlHelper
focal_class.var_name: xmlHelper
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/impl/EmrHelperServiceImpl.java
focal_class.identifier: EmrHelperServiceImpl
focal_class.interfaces: implements EmrHelperService
focal_class.class_method_signature: EmrHelperServiceImpl.emrCreateClusterAwsSpecificSteps(EmrClusterCreateRequest emrClusterCreateRequest, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.full_signature: @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) public EmrClusterCreateDto emrCreateClusterAwsSpecificSteps(EmrClusterCreateRequest emrClusterCreateRequest, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.identifier: emrCreateClusterAwsSpecificSteps
focal_class.modifiers: @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) public
focal_class.parameters: (EmrClusterCreateRequest emrClusterCreateRequest, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.return: EmrClusterCreateDto
focal_class.signature: EmrClusterCreateDto emrCreateClusterAwsSpecificSteps(EmrClusterCreateRequest emrClusterCreateRequest, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.class_method_signature: EmrHelperServiceImpl.emrPreCreateClusterSteps(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest emrClusterCreateRequest)
focal_class.full_signature: @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public EmrClusterPreCreateDto emrPreCreateClusterSteps(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest emrClusterCreateRequest)
focal_class.identifier: emrPreCreateClusterSteps
focal_class.modifiers: @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public
focal_class.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest emrClusterCreateRequest)
focal_class.return: EmrClusterPreCreateDto
focal_class.signature: EmrClusterPreCreateDto emrPreCreateClusterSteps(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest emrClusterCreateRequest)
focal_class.class_method_signature: EmrHelperServiceImpl.logEmrClusterCreation(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.full_signature: @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void logEmrClusterCreation(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.identifier: logEmrClusterCreation
focal_class.modifiers: @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public
focal_class.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.return: void
focal_class.signature: void logEmrClusterCreation(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.class_method_signature: EmrHelperServiceImpl.emrCreateClusterAwsSpecificStepsImpl(EmrClusterCreateRequest request, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.full_signature:  EmrClusterCreateDto emrCreateClusterAwsSpecificStepsImpl(EmrClusterCreateRequest request, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.identifier: emrCreateClusterAwsSpecificStepsImpl
focal_class.parameters: (EmrClusterCreateRequest request, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.return: EmrClusterCreateDto
focal_class.signature: EmrClusterCreateDto emrCreateClusterAwsSpecificStepsImpl(EmrClusterCreateRequest request, EmrClusterDefinition emrClusterDefinition,
          EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto)
focal_class.class_method_signature: EmrHelperServiceImpl.emrPreCreateClusterStepsImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest request)
focal_class.full_signature:  EmrClusterPreCreateDto emrPreCreateClusterStepsImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest request)
focal_class.identifier: emrPreCreateClusterStepsImpl
focal_class.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest request)
focal_class.return: EmrClusterPreCreateDto
focal_class.signature: EmrClusterPreCreateDto emrPreCreateClusterStepsImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest request)
focal_class.class_method_signature: EmrHelperServiceImpl.logEmrClusterCreationImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.full_signature:  void logEmrClusterCreationImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.identifier: logEmrClusterCreationImpl
focal_class.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.return: void
focal_class.signature: void logEmrClusterCreationImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId)
focal_class.class_method_signature: EmrHelperServiceImpl.getS3ManagedReplaceString()
focal_class.full_signature: private String getS3ManagedReplaceString()
focal_class.identifier: getS3ManagedReplaceString
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getS3ManagedReplaceString()
focal_class.class_method_signature: EmrHelperServiceImpl.overrideEmrClusterDefinition(EmrClusterDefinition emrClusterDefinition, EmrClusterDefinition emrClusterDefinitionOverride)
focal_class.full_signature: @SuppressWarnings("PMD.CyclomaticComplexity") // Method is not complex. It's just very repetitive. protected void overrideEmrClusterDefinition(EmrClusterDefinition emrClusterDefinition, EmrClusterDefinition emrClusterDefinitionOverride)
focal_class.identifier: overrideEmrClusterDefinition
focal_class.modifiers: @SuppressWarnings("PMD.CyclomaticComplexity") // Method is not complex. It's just very repetitive. protected
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition, EmrClusterDefinition emrClusterDefinitionOverride)
focal_class.return: void
focal_class.signature: void overrideEmrClusterDefinition(EmrClusterDefinition emrClusterDefinition, EmrClusterDefinition emrClusterDefinitionOverride)
focal_class.class_method_signature: EmrHelperServiceImpl.updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.full_signature:  void updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.identifier: updateEmrClusterDefinitionWithValidInstanceFleetSubnets
focal_class.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.return: void
focal_class.signature: void updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.body: void updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
      {
          // Get total count of instances this definition will attempt to create
          Integer instanceFleetMinimumIpAvailableFilter = emrClusterDefinition.getInstanceFleetMinimumIpAvailableFilter();
  
          if (instanceFleetMinimumIpAvailableFilter == null || instanceFleetMinimumIpAvailableFilter == 0)
          {
              return;
          }
  
          // Get the subnet information
          // Makes AWS EC2 call DescribeSubnets
  
          List<Subnet> subnets = emrPricingHelper.getSubnets(emrClusterDefinition, awsParamsDto);
  
          List<String> validSubnetIds =
              subnets.stream().filter(subnet -> subnet.getAvailableIpAddressCount() >= instanceFleetMinimumIpAvailableFilter).map(Subnet::getSubnetId)
                  .collect(Collectors.toList());
  
          String contextInfo = String.format("namespace=\"%s\" emrClusterDefinitionName=\"%s\" emrClusterName=\"%s\" " +
                  "instanceFleetMinimumIpAvailableFilter=%s subnetAvailableIpAddressCounts=%s validSubnetIds=%s", emrClusterAlternateKeyDto.getNamespace(),
              emrClusterAlternateKeyDto.getEmrClusterDefinitionName(), emrClusterAlternateKeyDto.getEmrClusterName(), instanceFleetMinimumIpAvailableFilter,
              jsonHelper.objectToJson(subnets.stream().collect(Collectors.toMap(Subnet::getSubnetId, Subnet::getAvailableIpAddressCount))),
              validSubnetIds.toString());
  
          LOGGER.info("Current IP availability: {}", contextInfo);
  
          if (validSubnetIds.isEmpty())
          {
              throw new IllegalArgumentException(
                  "Specified subnets do not have enough available IP addresses required for the instance fleet. " + "Current IP availability: " + contextInfo);
          }
  
          // Pass list of valid subnet ids back to EMR cluster definition
          emrClusterDefinition.setSubnetId(String.join(",", validSubnetIds));
      }
focal_method.class_method_signature: EmrHelperServiceImpl.updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.full_signature:  void updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.identifier: updateEmrClusterDefinitionWithValidInstanceFleetSubnets
focal_method.invocations: getInstanceFleetMinimumIpAvailableFilter getSubnets collect map filter stream getAvailableIpAddressCount toList format getNamespace getEmrClusterDefinitionName getEmrClusterName objectToJson collect stream toMap toString info isEmpty setSubnetId join
focal_method.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.return: void
focal_method.signature: void updateEmrClusterDefinitionWithValidInstanceFleetSubnets(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)