EmrDaoImpl implements EmrDao { protected List<InstanceTypeConfig> getInstanceTypeConfigs(List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs) { List<InstanceTypeConfig> instanceTypeConfigs = null; if (!CollectionUtils.isEmpty(emrClusterDefinitionInstanceTypeConfigs)) { instanceTypeConfigs = new ArrayList<>(); for (EmrClusterDefinitionInstanceTypeConfig emrClusterDefinitionInstanceTypeConfig : emrClusterDefinitionInstanceTypeConfigs) { if (emrClusterDefinitionInstanceTypeConfig != null) { InstanceTypeConfig instanceTypeConfig = new InstanceTypeConfig(); instanceTypeConfig.setInstanceType(emrClusterDefinitionInstanceTypeConfig.getInstanceType()); instanceTypeConfig.setWeightedCapacity(emrClusterDefinitionInstanceTypeConfig.getWeightedCapacity()); instanceTypeConfig.setBidPrice(emrClusterDefinitionInstanceTypeConfig.getBidPrice()); instanceTypeConfig.setBidPriceAsPercentageOfOnDemandPrice(emrClusterDefinitionInstanceTypeConfig.getBidPriceAsPercentageOfOnDemandPrice()); instanceTypeConfig.setEbsConfiguration(getEbsConfiguration(emrClusterDefinitionInstanceTypeConfig.getEbsConfiguration())); instanceTypeConfig.setConfigurations(getConfigurations(emrClusterDefinitionInstanceTypeConfig.getConfigurations())); instanceTypeConfigs.add(instanceTypeConfig); } } } return instanceTypeConfigs; }  @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 testGetInstanceTypeConfigs() { final String instanceType = STRING_VALUE; final Integer weightedCapacity = INTEGER_VALUE; final String bidPrice = STRING_VALUE_2; final Double bidPriceAsPercentageOfOnDemandPrice = DOUBLE_VALUE; final EmrClusterDefinitionEbsConfiguration emrClusterDefinitionEbsConfiguration = null; final List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations = null; final EmrClusterDefinitionInstanceTypeConfig emrClusterDefinitionInstanceTypeConfig = new EmrClusterDefinitionInstanceTypeConfig(instanceType, weightedCapacity, bidPrice, bidPriceAsPercentageOfOnDemandPrice, emrClusterDefinitionEbsConfiguration, emrClusterDefinitionConfigurations); List<InstanceTypeConfig> result = emrDaoImpl.getInstanceTypeConfigs(Lists.newArrayList(emrClusterDefinitionInstanceTypeConfig)); verifyNoMoreInteractionsHelper(); final List<Configuration> expectedConfigurations = null; assertEquals(Lists.newArrayList(new InstanceTypeConfig().withInstanceType(instanceType).withWeightedCapacity(weightedCapacity).withBidPrice(bidPrice) .withBidPriceAsPercentageOfOnDemandPrice(bidPriceAsPercentageOfOnDemandPrice).withEbsConfiguration(null) .withConfigurations(expectedConfigurations)), result); }
@Test public void testGetInstanceTypeConfigsWhenInputListContainsNullElement() { List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs = new ArrayList<>(); emrClusterDefinitionInstanceTypeConfigs.add(null); List<InstanceTypeConfig> result = emrDaoImpl.getInstanceTypeConfigs(emrClusterDefinitionInstanceTypeConfigs); verifyNoMoreInteractionsHelper(); assertEquals(new ArrayList<>(), result); }