EmrDaoImpl implements EmrDao { protected List<Configuration> getConfigurations(List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations) { List<Configuration> configurations = null; if (!CollectionUtils.isEmpty(emrClusterDefinitionConfigurations)) { configurations = new ArrayList<>(); for (EmrClusterDefinitionConfiguration emrClusterDefinitionConfiguration : emrClusterDefinitionConfigurations) { if (emrClusterDefinitionConfiguration != null) { Configuration configuration = new Configuration(); configuration.setClassification(emrClusterDefinitionConfiguration.getClassification()); configuration.setConfigurations(getConfigurations(emrClusterDefinitionConfiguration.getConfigurations())); configuration.setProperties(getMap(emrClusterDefinitionConfiguration.getProperties())); configurations.add(configuration); } } } return configurations; }  @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 testGetConfigurations() { final String classification = STRING_VALUE; final List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations = null; final List<Parameter> properties = null; final EmrClusterDefinitionConfiguration emrClusterDefinitionConfiguration = new EmrClusterDefinitionConfiguration(classification, emrClusterDefinitionConfigurations, properties); List<Configuration> result = emrDaoImpl.getConfigurations(Lists.newArrayList(emrClusterDefinitionConfiguration)); verifyNoMoreInteractionsHelper(); final List<Configuration> expectedConfigurations = null; assertEquals(Lists.newArrayList(new Configuration().withClassification(classification).withConfigurations(expectedConfigurations).withProperties(null)), result); }
@Test public void testGetConfigurationsWhenInputListContainsNullElement() { List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations = new ArrayList<>(); emrClusterDefinitionConfigurations.add(null); List<Configuration> result = emrDaoImpl.getConfigurations(emrClusterDefinitionConfigurations); verifyNoMoreInteractionsHelper(); assertEquals(new ArrayList<>(), result); }
@Test public void testGetConfigurationsWhenInputListIsEmpty() { List<Configuration> result = emrDaoImpl.getConfigurations(new ArrayList<>()); verifyNoMoreInteractionsHelper(); assertNull(result); }