EmrDaoImpl implements EmrDao { protected List<InstanceFleetConfig> getInstanceFleets(List<EmrClusterDefinitionInstanceFleet> emrClusterDefinitionInstanceFleets) { List<InstanceFleetConfig> instanceFleets = null; if (!CollectionUtils.isEmpty(emrClusterDefinitionInstanceFleets)) { instanceFleets = new ArrayList<>(); for (EmrClusterDefinitionInstanceFleet emrClusterDefinitionInstanceFleet : emrClusterDefinitionInstanceFleets) { if (emrClusterDefinitionInstanceFleet != null) { InstanceFleetConfig instanceFleetConfig = new InstanceFleetConfig(); instanceFleetConfig.setName(emrClusterDefinitionInstanceFleet.getName()); instanceFleetConfig.setInstanceFleetType(emrClusterDefinitionInstanceFleet.getInstanceFleetType()); instanceFleetConfig.setTargetOnDemandCapacity(emrClusterDefinitionInstanceFleet.getTargetOnDemandCapacity()); instanceFleetConfig.setTargetSpotCapacity(emrClusterDefinitionInstanceFleet.getTargetSpotCapacity()); instanceFleetConfig.setInstanceTypeConfigs(getInstanceTypeConfigs(emrClusterDefinitionInstanceFleet.getInstanceTypeConfigs())); instanceFleetConfig.setLaunchSpecifications(getLaunchSpecifications(emrClusterDefinitionInstanceFleet.getLaunchSpecifications())); instanceFleets.add(instanceFleetConfig); } } } return instanceFleets; }  @Override String addEmrStep(String clusterId, StepConfig emrStepConfig, AwsParamsDto awsParamsDto); @Override String createEmrCluster(String clusterName, EmrClusterDefinition emrClusterDefinition, EmrParamsDto emrParamsDto); @Override synchronized ClusterSummary getActiveEmrClusterByNameAndAccountId(String clusterName, String accountId, AwsParamsDto awsParams); List<Application> getApplications(List<EmrClusterDefinitionApplication> emrClusterDefinitionApplications); @Override StepSummary getClusterActiveStep(String clusterId, AwsParamsDto awsParamsDto); @Override Step getClusterStep(String clusterId, String stepId, AwsParamsDto awsParamsDto); @Override AmazonElasticMapReduceClient getEmrClient(AwsParamsDto awsParamsDto); @Override Cluster getEmrClusterById(String clusterId, AwsParamsDto awsParams); @Override String getEmrClusterStatusById(String clusterId, AwsParamsDto awsParams); @Override Instance getEmrMasterInstance(String clusterId, AwsParamsDto awsParams); @Override ListInstanceFleetsResult getListInstanceFleetsResult(String clusterId, AwsParamsDto awsParams); @Override void terminateEmrCluster(String clusterId, boolean overrideTerminationProtection, AwsParamsDto awsParams);  }
@Test public void testGetInstanceFleets() { final String name = STRING_VALUE; final String instanceFleetType = STRING_VALUE_2; final Integer targetOnDemandCapacity = INTEGER_VALUE; final Integer targetSpotCapacity = INTEGER_VALUE_2; final List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs = null; final EmrClusterDefinitionSpotSpecification emrClusterDefinitionSpotSpecification = new EmrClusterDefinitionSpotSpecification(TIMEOUT_DURATION_MINUTES, TIMEOUT_ACTION, BLOCK_DURATION_MINUTES, ALLOCATION_STRATEGY_1); final EmrClusterDefinitionOnDemandSpecification emrClusterDefinitionOnDemandSpecification = new EmrClusterDefinitionOnDemandSpecification(ALLOCATION_STRATEGY_2); final EmrClusterDefinitionLaunchSpecifications emrClusterDefinitionLaunchSpecifications = new EmrClusterDefinitionLaunchSpecifications(emrClusterDefinitionSpotSpecification, emrClusterDefinitionOnDemandSpecification); final EmrClusterDefinitionInstanceFleet emrClusterDefinitionInstanceFleet = new EmrClusterDefinitionInstanceFleet(name, instanceFleetType, targetOnDemandCapacity, targetSpotCapacity, emrClusterDefinitionInstanceTypeConfigs, emrClusterDefinitionLaunchSpecifications); List<InstanceFleetConfig> result = emrDaoImpl.getInstanceFleets(Lists.newArrayList(emrClusterDefinitionInstanceFleet)); verifyNoMoreInteractionsHelper(); final List<InstanceTypeConfig> expectedInstanceTypeConfigs = null; assertEquals(Lists.newArrayList( new InstanceFleetConfig().withName(name).withInstanceFleetType(instanceFleetType).withTargetOnDemandCapacity(targetOnDemandCapacity) .withTargetSpotCapacity(targetSpotCapacity).withInstanceTypeConfigs(expectedInstanceTypeConfigs).withLaunchSpecifications( new InstanceFleetProvisioningSpecifications().withSpotSpecification( new SpotProvisioningSpecification().withAllocationStrategy(ALLOCATION_STRATEGY_1).withBlockDurationMinutes(BLOCK_DURATION_MINUTES) .withTimeoutAction(TIMEOUT_ACTION).withTimeoutDurationMinutes(TIMEOUT_DURATION_MINUTES)) .withOnDemandSpecification(new OnDemandProvisioningSpecification().withAllocationStrategy(ALLOCATION_STRATEGY_2)))), result); }
@Test public void testGetInstanceFleetsWhenInputListContainsNullElement() { List<EmrClusterDefinitionInstanceFleet> emrClusterDefinitionInstanceFleets = new ArrayList<>(); emrClusterDefinitionInstanceFleets.add(null); List<InstanceFleetConfig> result = emrDaoImpl.getInstanceFleets(emrClusterDefinitionInstanceFleets); verifyNoMoreInteractionsHelper(); assertEquals(new ArrayList<>(), result); }
@Test public void testGetInstanceFleetsWhenEmrClusterDefinitionInstanceFleetsListIsNull() { List<InstanceFleetConfig> result = emrDaoImpl.getInstanceFleets(null); verifyNoMoreInteractionsHelper(); assertNull(result); }