EmrDaoImpl implements EmrDao { protected InstanceFleetProvisioningSpecifications getLaunchSpecifications(EmrClusterDefinitionLaunchSpecifications emrClusterDefinitionLaunchSpecifications) { InstanceFleetProvisioningSpecifications instanceFleetProvisioningSpecifications = null; if (emrClusterDefinitionLaunchSpecifications != null) { instanceFleetProvisioningSpecifications = new InstanceFleetProvisioningSpecifications(); instanceFleetProvisioningSpecifications.setSpotSpecification(getSpotSpecification(emrClusterDefinitionLaunchSpecifications.getSpotSpecification())); instanceFleetProvisioningSpecifications .setOnDemandSpecification(getOnDemandSpecification(emrClusterDefinitionLaunchSpecifications.getOnDemandSpecification())); } return instanceFleetProvisioningSpecifications; }  @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 testGetLaunchSpecifications() { 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); InstanceFleetProvisioningSpecifications result = emrDaoImpl.getLaunchSpecifications(emrClusterDefinitionLaunchSpecifications); verifyNoMoreInteractionsHelper(); assertEquals(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 testGetLaunchSpecificationsWhenEmrClusterDefinitionSpotSpecificationIsNull() { InstanceFleetProvisioningSpecifications result = emrDaoImpl.getLaunchSpecifications(null); verifyNoMoreInteractionsHelper(); assertNull(result); }