@Test
public void testBuildEmrClusterInstanceFleetFromAwsResult()
{

    ListInstanceFleetsResult listInstanceFleetsResult = null;
    assertNull(emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    listInstanceFleetsResult = new ListInstanceFleetsResult();
    assertNull(emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String instanceId = "instance id";
    String instanceName = "instance name";
    String instanceFleetType = "instance fleet type";
    int targetOnDemandCapacity = 1;
    int targetSpotCapacity = 2;
    int provisionedOnDemandCapacity = 3;
    int provisionedSpotCapacity = 4;
    EmrClusterInstanceFleet expectedEmrInstanceFleet = new EmrClusterInstanceFleet();
    expectedEmrInstanceFleet.setId(instanceId);
    expectedEmrInstanceFleet.setName(instanceName);
    expectedEmrInstanceFleet.setInstanceFleetType(instanceFleetType);
    expectedEmrInstanceFleet.setTargetOnDemandCapacity(targetOnDemandCapacity);
    expectedEmrInstanceFleet.setTargetSpotCapacity(targetSpotCapacity);
    expectedEmrInstanceFleet.setProvisionedOnDemandCapacity(provisionedOnDemandCapacity);
    expectedEmrInstanceFleet.setProvisionedSpotCapacity(provisionedSpotCapacity);
    InstanceFleet instanceFleet = new InstanceFleet();
    instanceFleet.setId(instanceId);
    instanceFleet.setName(instanceName);
    instanceFleet.setInstanceFleetType(instanceFleetType);
    instanceFleet.setTargetOnDemandCapacity(targetOnDemandCapacity);
    instanceFleet.setTargetSpotCapacity(targetSpotCapacity);
    instanceFleet.setProvisionedSpotCapacity(provisionedSpotCapacity);
    instanceFleet.setProvisionedOnDemandCapacity(provisionedOnDemandCapacity);
    List<InstanceFleet> instanceFleets = new ArrayList<>();
    instanceFleets.add(null);
    instanceFleets.add(instanceFleet);
    listInstanceFleetsResult.setInstanceFleets(instanceFleets);
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    EmrClusterInstanceFleetStatus emrClusterInstanceFleetStatus = new EmrClusterInstanceFleetStatus();
    String emrClusterInstanceFleetStatus_State = "state 1";
    emrClusterInstanceFleetStatus.setState(emrClusterInstanceFleetStatus_State);
    expectedEmrInstanceFleet.setInstanceFleetStatus(emrClusterInstanceFleetStatus);
    InstanceFleetStatus instanceFleetStatus = new InstanceFleetStatus();
    instanceFleetStatus.setState(emrClusterInstanceFleetStatus_State);
    instanceFleet.setStatus(instanceFleetStatus);
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String emrClusterInstanceFleetStatus_StateChangeCode = "change code 1";
    String emrClusterInstanceFleetStatus_StateChangeMsg = "change msg 1";
    InstanceFleetStateChangeReason instanceFleetStateChangeReason = new InstanceFleetStateChangeReason();
    instanceFleetStateChangeReason.setCode(emrClusterInstanceFleetStatus_StateChangeCode);
    instanceFleetStateChangeReason.setMessage(emrClusterInstanceFleetStatus_StateChangeMsg);
    instanceFleetStatus.setStateChangeReason(instanceFleetStateChangeReason);
    InstanceFleetTimeline instanceFleetTimeline = new InstanceFleetTimeline();
    java.util.Date now = Calendar.getInstance().getTime();
    instanceFleetTimeline.setCreationDateTime(now);
    instanceFleetTimeline.setReadyDateTime(now);
    instanceFleetTimeline.setEndDateTime(now);
    instanceFleetStatus.setTimeline(instanceFleetTimeline);
    EmrClusterInstanceFleetStateChangeReason emrClusterInstanceFleetStateChangeReason = new EmrClusterInstanceFleetStateChangeReason();
    emrClusterInstanceFleetStateChangeReason.setCode(emrClusterInstanceFleetStatus_StateChangeCode);
    emrClusterInstanceFleetStateChangeReason.setMessage(emrClusterInstanceFleetStatus_StateChangeMsg);
    emrClusterInstanceFleetStatus.setStateChangeReason(emrClusterInstanceFleetStateChangeReason);
    EmrClusterInstanceFleetTimeline emrClusterInstanceFleetTimeline = new EmrClusterInstanceFleetTimeline();
    emrClusterInstanceFleetTimeline.setCreationDateTime(HerdDateUtils.getXMLGregorianCalendarValue(now));
    emrClusterInstanceFleetTimeline.setReadyDateTime(HerdDateUtils.getXMLGregorianCalendarValue(now));
    emrClusterInstanceFleetTimeline.setEndDateTime(HerdDateUtils.getXMLGregorianCalendarValue(now));
    emrClusterInstanceFleetStatus.setTimeline(emrClusterInstanceFleetTimeline);
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String instanceType = "instance type 1";
    int weightedCapacity = 1;
    String bidPrice = "1.0";
    double bidPricePercent = 0.8;
    boolean ebsOptimized = true;
    InstanceTypeSpecification instanceTypeSpecification = new InstanceTypeSpecification();
    instanceTypeSpecification.setInstanceType(instanceType);
    instanceTypeSpecification.setWeightedCapacity(weightedCapacity);
    instanceTypeSpecification.setBidPrice(bidPrice);
    instanceTypeSpecification.setBidPriceAsPercentageOfOnDemandPrice(bidPricePercent);
    instanceTypeSpecification.setEbsOptimized(ebsOptimized);
    List<InstanceTypeSpecification> instanceTypeSpecifications = new ArrayList<>();
    instanceTypeSpecifications.add(null);
    instanceTypeSpecifications.add(instanceTypeSpecification);
    instanceFleet.setInstanceTypeSpecifications(instanceTypeSpecifications);
    EmrClusterInstanceTypeSpecification emrClusterInstanceTypeSpecification = new EmrClusterInstanceTypeSpecification();
    emrClusterInstanceTypeSpecification.setInstanceType(instanceType);
    emrClusterInstanceTypeSpecification.setWeightedCapacity(weightedCapacity);
    emrClusterInstanceTypeSpecification.setBidPrice(bidPrice);
    emrClusterInstanceTypeSpecification.setBidPriceAsPercentageOfOnDemandPrice(bidPricePercent);
    emrClusterInstanceTypeSpecification.setEbsOptimized(ebsOptimized);
    expectedEmrInstanceFleet.setInstanceTypeSpecifications(Lists.newArrayList(emrClusterInstanceTypeSpecification));
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    EbsBlockDevice ebsBlockDevice = new EbsBlockDevice();
    String device = "device 1";
    ebsBlockDevice.setDevice(device);
    List<EbsBlockDevice> ebsBlockDevices = new ArrayList<>();
    ebsBlockDevices.add(ebsBlockDevice);
    ebsBlockDevices.add(null);
    instanceTypeSpecification.setEbsBlockDevices(ebsBlockDevices);
    EmrClusterEbsBlockDevice emrClusterEbsBlockDevice = new EmrClusterEbsBlockDevice();
    emrClusterEbsBlockDevice.setDevice(device);
    emrClusterInstanceTypeSpecification.setEbsBlockDevices(Lists.newArrayList(emrClusterEbsBlockDevice));
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    int iops = 100;
    int sizeInGB = 20;
    String volumeType = "volume type 1";
    VolumeSpecification volumeSpecification = new VolumeSpecification();
    volumeSpecification.setIops(iops);
    volumeSpecification.setSizeInGB(sizeInGB);
    volumeSpecification.setVolumeType(volumeType);
    ebsBlockDevice.setVolumeSpecification(volumeSpecification);
    EmrClusterVolumeSpecification emrClusterVolumeSpecification = new EmrClusterVolumeSpecification();
    emrClusterVolumeSpecification.setIops(iops);
    emrClusterVolumeSpecification.setSizeInGB(sizeInGB);
    emrClusterVolumeSpecification.setVolumeType(volumeType);
    emrClusterEbsBlockDevice.setVolumeSpecification(emrClusterVolumeSpecification);
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    InstanceFleetProvisioningSpecifications instanceFleetProvisioningSpecifications = new InstanceFleetProvisioningSpecifications();
    instanceFleet.setLaunchSpecifications(instanceFleetProvisioningSpecifications);
    EmrClusterInstanceFleetProvisioningSpecifications emrClusterInstanceFleetProvisioningSpecifications =
        new EmrClusterInstanceFleetProvisioningSpecifications();
    expectedEmrInstanceFleet.setLaunchSpecifications(emrClusterInstanceFleetProvisioningSpecifications);
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    List<Configuration> configurations = new ArrayList<>();
    Configuration configuration = new Configuration();
    String classification = "classification 1";
    configuration.setClassification(classification);
    configurations.add(null);
    configurations.add(configuration);
    instanceTypeSpecification.setConfigurations(configurations);
    EmrClusterInstanceTypeConfiguration emrClusterInstanceTypeConfiguration = new EmrClusterInstanceTypeConfiguration();
    emrClusterInstanceTypeConfiguration.setClassification(classification);
    emrClusterInstanceTypeSpecification.setConfigurations(Lists.newArrayList(emrClusterInstanceTypeConfiguration));
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String paramKey = "param 1";
    String paramVal = "param val 1";
    java.util.Map<String, String> map = new HashMap<>();
    map.put(paramKey, paramVal);
    configuration.setProperties(map);
    Parameter parameter = new Parameter(paramKey, paramVal);
    emrClusterInstanceTypeConfiguration.setProperties(Lists.newArrayList(parameter));
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    int blockDurationMin = 30;
    String timeoutAction = "action 1";
    int timeoutDurationMin = 60;
    //to do time out action
    SpotProvisioningSpecification spotProvisioningSpecification = new SpotProvisioningSpecification();
    spotProvisioningSpecification.setBlockDurationMinutes(blockDurationMin);
    spotProvisioningSpecification.setTimeoutAction(timeoutAction);
    spotProvisioningSpecification.setTimeoutDurationMinutes(timeoutDurationMin);
    instanceFleetProvisioningSpecifications.setSpotSpecification(spotProvisioningSpecification);
    EmrClusterSpotProvisioningSpecification emrClusterSpotProvisioningSpecification = new EmrClusterSpotProvisioningSpecification();
    emrClusterSpotProvisioningSpecification.setBlockDurationMinutes(blockDurationMin);
    emrClusterSpotProvisioningSpecification.setTimeoutAction(timeoutAction);
    emrClusterSpotProvisioningSpecification.setTimeoutDurationMinutes(timeoutDurationMin);
    emrClusterInstanceFleetProvisioningSpecifications.setSpotSpecification(emrClusterSpotProvisioningSpecification);
    assertEquals(Lists.newArrayList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
}