EmrHelperServiceImpl implements EmrHelperService { @SuppressWarnings("PMD.CyclomaticComplexity") protected void overrideEmrClusterDefinition(EmrClusterDefinition emrClusterDefinition, EmrClusterDefinition emrClusterDefinitionOverride) { if (emrClusterDefinitionOverride != null) { if (emrClusterDefinitionOverride.getReleaseLabel() != null) { emrClusterDefinition.setReleaseLabel(emrClusterDefinitionOverride.getReleaseLabel()); } if (emrClusterDefinitionOverride.getApplications() != null) { emrClusterDefinition.setApplications(emrClusterDefinitionOverride.getApplications()); } if (emrClusterDefinitionOverride.getConfigurations() != null) { emrClusterDefinition.setConfigurations(emrClusterDefinitionOverride.getConfigurations()); } if (emrClusterDefinitionOverride.getSshKeyPairName() != null) { emrClusterDefinition.setSshKeyPairName(emrClusterDefinitionOverride.getSshKeyPairName()); } if (emrClusterDefinitionOverride.getSubnetId() != null) { emrClusterDefinition.setSubnetId(emrClusterDefinitionOverride.getSubnetId()); } if (emrClusterDefinitionOverride.getLogBucket() != null) { emrClusterDefinition.setLogBucket(emrClusterDefinitionOverride.getLogBucket()); } if (emrClusterDefinitionOverride.isKeepAlive() != null) { emrClusterDefinition.setKeepAlive(emrClusterDefinitionOverride.isKeepAlive()); } if (emrClusterDefinitionOverride.isVisibleToAll() != null) { emrClusterDefinition.setVisibleToAll(emrClusterDefinitionOverride.isVisibleToAll()); } if (emrClusterDefinitionOverride.isTerminationProtection() != null) { emrClusterDefinition.setTerminationProtection(emrClusterDefinitionOverride.isTerminationProtection()); } if (emrClusterDefinitionOverride.isEncryptionEnabled() != null) { emrClusterDefinition.setEncryptionEnabled(emrClusterDefinitionOverride.isEncryptionEnabled()); } if (emrClusterDefinitionOverride.getAmiVersion() != null) { emrClusterDefinition.setAmiVersion(emrClusterDefinitionOverride.getAmiVersion()); } if (emrClusterDefinitionOverride.getHadoopVersion() != null) { emrClusterDefinition.setHadoopVersion(emrClusterDefinitionOverride.getHadoopVersion()); } if (emrClusterDefinitionOverride.getHiveVersion() != null) { emrClusterDefinition.setHiveVersion(emrClusterDefinitionOverride.getHiveVersion()); } if (emrClusterDefinitionOverride.getPigVersion() != null) { emrClusterDefinition.setPigVersion(emrClusterDefinitionOverride.getPigVersion()); } if (emrClusterDefinitionOverride.getEc2NodeIamProfileName() != null) { emrClusterDefinition.setEc2NodeIamProfileName(emrClusterDefinitionOverride.getEc2NodeIamProfileName()); } if (emrClusterDefinitionOverride.isInstallOozie() != null) { emrClusterDefinition.setInstallOozie(emrClusterDefinitionOverride.isInstallOozie()); } if (emrClusterDefinitionOverride.getCustomBootstrapActionMaster() != null) { emrClusterDefinition.setCustomBootstrapActionMaster(emrClusterDefinitionOverride.getCustomBootstrapActionMaster()); } if (emrClusterDefinitionOverride.getCustomBootstrapActionAll() != null) { emrClusterDefinition.setCustomBootstrapActionAll(emrClusterDefinitionOverride.getCustomBootstrapActionAll()); } if (emrClusterDefinitionOverride.getAdditionalInfo() != null) { emrClusterDefinition.setAdditionalInfo(emrClusterDefinitionOverride.getAdditionalInfo()); } if (emrClusterDefinitionOverride.getInstanceDefinitions() != null) { emrClusterDefinition.setInstanceDefinitions(emrClusterDefinitionOverride.getInstanceDefinitions()); } if (emrClusterDefinitionOverride.getInstanceFleetMinimumIpAvailableFilter() != null) { emrClusterDefinition.setInstanceFleetMinimumIpAvailableFilter(emrClusterDefinitionOverride.getInstanceFleetMinimumIpAvailableFilter()); } if (emrClusterDefinitionOverride.getInstanceFleets() != null) { emrClusterDefinition.setInstanceFleets(emrClusterDefinitionOverride.getInstanceFleets()); } if (emrClusterDefinitionOverride.getNodeTags() != null) { emrClusterDefinition.setNodeTags(emrClusterDefinitionOverride.getNodeTags()); } if (emrClusterDefinitionOverride.getDaemonConfigurations() != null) { emrClusterDefinition.setDaemonConfigurations(emrClusterDefinitionOverride.getDaemonConfigurations()); } if (emrClusterDefinitionOverride.getHadoopConfigurations() != null) { emrClusterDefinition.setHadoopConfigurations(emrClusterDefinitionOverride.getHadoopConfigurations()); } if (emrClusterDefinitionOverride.getAccountId() != null) { emrClusterDefinition.setAccountId(emrClusterDefinitionOverride.getAccountId()); } if (emrClusterDefinitionOverride.getServiceIamRole() != null) { emrClusterDefinition.setServiceIamRole(emrClusterDefinitionOverride.getServiceIamRole()); } if (emrClusterDefinitionOverride.getSupportedProduct() != null) { emrClusterDefinition.setSupportedProduct(emrClusterDefinitionOverride.getSupportedProduct()); } if (emrClusterDefinitionOverride.getHadoopJarSteps() != null) { emrClusterDefinition.setHadoopJarSteps(emrClusterDefinitionOverride.getHadoopJarSteps()); } if (emrClusterDefinitionOverride.getAdditionalMasterSecurityGroups() != null) { emrClusterDefinition.setAdditionalMasterSecurityGroups(emrClusterDefinitionOverride.getAdditionalMasterSecurityGroups()); } if (emrClusterDefinitionOverride.getAdditionalSlaveSecurityGroups() != null) { emrClusterDefinition.setAdditionalSlaveSecurityGroups(emrClusterDefinitionOverride.getAdditionalSlaveSecurityGroups()); } if (emrClusterDefinitionOverride.getSecurityConfiguration() != null) { emrClusterDefinition.setSecurityConfiguration(emrClusterDefinitionOverride.getSecurityConfiguration()); } if (emrClusterDefinitionOverride.getMasterSecurityGroup() != null) { emrClusterDefinition.setMasterSecurityGroup(emrClusterDefinitionOverride.getMasterSecurityGroup()); } if (emrClusterDefinitionOverride.getSlaveSecurityGroup() != null) { emrClusterDefinition.setSlaveSecurityGroup(emrClusterDefinitionOverride.getSlaveSecurityGroup()); } if (emrClusterDefinitionOverride.getServiceAccessSecurityGroup() != null) { emrClusterDefinition.setServiceAccessSecurityGroup(emrClusterDefinitionOverride.getServiceAccessSecurityGroup()); } if (emrClusterDefinitionOverride.getScaleDownBehavior() != null) { emrClusterDefinition.setScaleDownBehavior(emrClusterDefinitionOverride.getScaleDownBehavior()); } if (emrClusterDefinitionOverride.getKerberosAttributes() != null) { emrClusterDefinition.setKerberosAttributes(emrClusterDefinitionOverride.getKerberosAttributes()); } if (emrClusterDefinitionOverride.getStepConcurrencyLevel() != null) { emrClusterDefinition.setStepConcurrencyLevel(emrClusterDefinitionOverride.getStepConcurrencyLevel()); } } }  @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) EmrClusterCreateDto emrCreateClusterAwsSpecificSteps(EmrClusterCreateRequest emrClusterCreateRequest, EmrClusterDefinition emrClusterDefinition,
        EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrParamsDto emrParamsDto); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) EmrClusterPreCreateDto emrPreCreateClusterSteps(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterCreateRequest emrClusterCreateRequest); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void logEmrClusterCreation(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition, String clusterId);  }
@Test public void testOverrideEmrClusterDefinition() { EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition("sshKeyPairName", "subnetId", "logBucket", true, true, true, true, "accountId", "serviceIamRole", "ec2NodeIamProfileName", "amiVersion", "releaseLabel", "hadoopVersion", "hiveVersion", "pigVersion", true, Lists.newArrayList(new ScriptDefinition()), Lists.newArrayList(new ScriptDefinition()), "additionalInfo", new InstanceDefinitions(), 0, Lists.newArrayList(new EmrClusterDefinitionInstanceFleet()), Lists.newArrayList(new NodeTag()), "supportedProduct", Lists.newArrayList(new EmrClusterDefinitionApplication()), Lists.newArrayList(new EmrClusterDefinitionConfiguration()), Lists.newArrayList(new Parameter()), Lists.newArrayList(new Byte("0")), Lists.newArrayList(new HadoopJarStep()), Lists.newArrayList("additionalMasterSecurityGroups"), Lists.newArrayList("additionalSlaveSecurityGroups"), "securityConfiguration", "masterSecurityGroup", "slaveSecurityGroup", "serviceAccessSecurityGroup", "scaleDownBehavior", new EmrClusterDefinitionKerberosAttributes(), 1); EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition("sshKeyPairNameOverride", "subnetIdOverride", "logBucketOverride", false, false, false, false, "accountIdOverride", "serviceIamRoleOverride", "ec2NodeIamProfileNameOverride", "amiVersionOverride", "releaseLabelOverride", "hadoopVersionOverride", "hiveVersionOverride", "pigVersionOverride", false, Lists.newArrayList(new ScriptDefinition(), new ScriptDefinition()), Lists.newArrayList(new ScriptDefinition(), new ScriptDefinition()), "additionalInfoOverride", new InstanceDefinitions(), 10, Lists.newArrayList(new EmrClusterDefinitionInstanceFleet(), new EmrClusterDefinitionInstanceFleet()), Lists.newArrayList(new NodeTag(), new NodeTag()), "supportedProductOverride", Lists.newArrayList(new EmrClusterDefinitionApplication(), new EmrClusterDefinitionApplication()), Lists.newArrayList(new EmrClusterDefinitionConfiguration(), new EmrClusterDefinitionConfiguration()), Lists.newArrayList(new Parameter(), new Parameter()), Lists.newArrayList(new Byte("0"), new Byte("0")), Lists.newArrayList(new HadoopJarStep(), new HadoopJarStep()), Lists.newArrayList("additionalMasterSecurityGroupsOverride", "additionalMasterSecurityGroupsOverride"), Lists.newArrayList("additionalSlaveSecurityGroupsOverride", "additionalSlaveSecurityGroupsOverride"), "securityConfigurationOverride", "masterSecurityGroupOverride", "slaveSecurityGroupOverride", "serviceSecurityGroupOverride", "scaleDownBehaviorOverride", new EmrClusterDefinitionKerberosAttributes(), 1); emrHelperServiceImpl.overrideEmrClusterDefinition(emrClusterDefinition, emrClusterDefinitionOverride); assertThat("Did not override.", emrClusterDefinition, is(emrClusterDefinitionOverride)); }
@Test public void testOverrideEmrClusterDefinitionNoOverride() { EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition("sshKeyPairName", "subnetId", "logBucket", true, true, true, true, "accountId", "serviceIamRole", "ec2NodeIamProfileName", "amiVersion", "releaseLabel", "hadoopVersion", "hiveVersion", "pigVersion", true, Lists.newArrayList(new ScriptDefinition()), Lists.newArrayList(new ScriptDefinition()), "additionalInfo", new InstanceDefinitions(), 0, Lists.newArrayList(new EmrClusterDefinitionInstanceFleet()), Lists.newArrayList(new NodeTag()), "supportedProduct", Lists.newArrayList(new EmrClusterDefinitionApplication()), Lists.newArrayList(new EmrClusterDefinitionConfiguration()), Lists.newArrayList(new Parameter()), Lists.newArrayList(new Byte("0")), Lists.newArrayList(new HadoopJarStep()), Lists.newArrayList("additionalMasterSecurityGroups"), Lists.newArrayList("additionalSlaveSecurityGroups"), "securityConfiguration", "masterSecurityGroup", "slaveSecurityGroup", "serviceAccessSecurityGroup", "scaleDownBehavior", new EmrClusterDefinitionKerberosAttributes(), 1); EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition(); emrHelperServiceImpl.overrideEmrClusterDefinition(emrClusterDefinition, emrClusterDefinitionOverride); assertThat("Should not override.", emrClusterDefinition, is(emrClusterDefinition)); }