/** * Create an instance of {@link EmrClusterAlternateKeyDto } * */ public EmrClusterAlternateKeyDto createEmrClusterAlternateKeyDto() { return new EmrClusterAlternateKeyDto(); }
public Object createNewInstance() { return new EmrClusterAlternateKeyDto(); }
@Override public EmrClusterAlternateKeyDto build() { if (_storedValue == null) { return this.init(new EmrClusterAlternateKeyDto()); } else { return ((EmrClusterAlternateKeyDto) _storedValue); } }
/** * Builds the cluster alternate key and returns. * * @param execution the DelegateExecution * * @return the cluster alternate key. */ protected EmrClusterAlternateKeyDto getClusterAlternateKey(DelegateExecution execution) { // Create the alternate key. EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(); emrClusterAlternateKeyDto.setNamespace(activitiHelper.getExpressionVariableAsString(namespace, execution)); emrClusterAlternateKeyDto.setEmrClusterDefinitionName(activitiHelper.getExpressionVariableAsString(emrClusterDefinitionName, execution)); emrClusterAlternateKeyDto.setEmrClusterName(activitiHelper.getExpressionVariableAsString(emrClusterName, execution)); return emrClusterAlternateKeyDto; }
/** * Builds the cluster alternate key and returns. * * @param execution the DelegateExecution * * @return the cluster alternate key. */ protected EmrClusterAlternateKeyDto getClusterAlternateKey(DelegateExecution execution) { // Create the alternate key. EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(); emrClusterAlternateKeyDto.setNamespace(activitiHelper.getExpressionVariableAsString(namespace, execution)); emrClusterAlternateKeyDto.setEmrClusterDefinitionName(activitiHelper.getExpressionVariableAsString(emrClusterDefinitionName, execution)); emrClusterAlternateKeyDto.setEmrClusterName(activitiHelper.getExpressionVariableAsString(emrClusterName, execution)); return emrClusterAlternateKeyDto; }
@Test public void testLogEmrClusterCreationImpl() throws Exception { // Create a namespace entity. NamespaceEntity namespaceEntity = new NamespaceEntity(); namespaceEntity.setCode(NAMESPACE); // Create an EMR cluster alternate key DTO EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME); // Create an EMR cluster definition object EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition(); // Mock the external calls. when(namespaceDaoHelper.getNamespaceEntity(NAMESPACE)).thenReturn(namespaceEntity); when(xmlHelper.objectToXml(emrClusterDefinition)).thenReturn(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH); // Call the method under test. emrHelperServiceImpl.logEmrClusterCreation(emrClusterAlternateKeyDto, emrClusterDefinition, EMR_CLUSTER_ID); // Verify the external calls. verify(namespaceDaoHelper).getNamespaceEntity(NAMESPACE); verify(xmlHelper).objectToXml(emrClusterDefinition); verify(herdDao).saveAndRefresh(any(EmrClusterCreationLogEntity.class)); verifyNoMoreInteractionsHelper(); }
@Test public void testTerminateEmrCluster() throws Exception { // Create an EMR cluster key. EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME); // Create an EMR cluster. EmrCluster emrCluster = new EmrCluster(); emrCluster.setId(EMR_CLUSTER_ID); // Mock the external calls. when(emrService.terminateCluster(emrClusterAlternateKeyDto, OVERRIDE_TERMINATION_PROTECTION, EMR_CLUSTER_ID, AWS_ACCOUNT_ID)).thenReturn(emrCluster); // Call the method under test. EmrCluster result = emrRestController .terminateEmrCluster(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME, OVERRIDE_TERMINATION_PROTECTION, EMR_CLUSTER_ID, AWS_ACCOUNT_ID); // Verify the external calls. verify(emrService).terminateCluster(emrClusterAlternateKeyDto, OVERRIDE_TERMINATION_PROTECTION, EMR_CLUSTER_ID, AWS_ACCOUNT_ID); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(emrCluster, result); }
String emrClusterId = "emrClusterId"; EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(); emrClusterAlternateKeyDto.setNamespace(namespace); emrClusterAlternateKeyDto.setEmrClusterDefinitionName(emrClusterDefinitionName);
@Test public void testGetEmrCluster() throws Exception { // Create an EMR cluster key. EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME); // Create an EMR cluster. EmrCluster emrCluster = new EmrCluster(); emrCluster.setId(EMR_CLUSTER_ID); // Mock the external calls. when(emrService.getCluster(emrClusterAlternateKeyDto, EMR_CLUSTER_ID, EMR_STEP_ID, EMR_CLUSTER_VERBOSE_FLAG, AWS_ACCOUNT_ID, RETRIEVE_INSTANCE_FLEETS)) .thenReturn(emrCluster); // Call the method under test. EmrCluster result = emrRestController .getEmrCluster(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME, EMR_CLUSTER_ID, EMR_STEP_ID, EMR_CLUSTER_VERBOSE_FLAG, AWS_ACCOUNT_ID, RETRIEVE_INSTANCE_FLEETS); // Verify the external calls. verify(emrService) .getCluster(emrClusterAlternateKeyDto, EMR_CLUSTER_ID, EMR_STEP_ID, EMR_CLUSTER_VERBOSE_FLAG, AWS_ACCOUNT_ID, RETRIEVE_INSTANCE_FLEETS); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(emrCluster, result); }
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME);
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME);
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME);
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME);
@Test public void testEmrCreateClusterAwsSpecificStepsImplDryRun() { // Create an AWS params DTO AwsParamsDto awsParamsDto = new AwsParamsDto(); // Create an EMR cluster definition object EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition(); emrClusterDefinition.setAccountId(AWS_ACCOUNT_ID); emrClusterDefinition.setInstanceDefinitions(new InstanceDefinitions()); // Create an EMR cluster create request EmrClusterCreateRequest emrClusterCreateRequest = new EmrClusterCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME, DRY_RUN, emrClusterDefinition); emrClusterCreateRequest.setEmrClusterDefinitionOverride(emrClusterDefinition); // Create an EMR cluster alternate key DTO EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = new EmrClusterAlternateKeyDto(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME); // Create a cluster summary object ClusterSummary clusterSummary = new ClusterSummary(); clusterSummary.setId(EMR_CLUSTER_ID); // Mock the external calls. when(emrHelper.getAwsParamsDtoByAccountId(emrClusterDefinition.getAccountId())).thenReturn(awsParamsDto); when(emrHelper.isInstanceDefinitionsEmpty(emrClusterDefinition.getInstanceDefinitions())).thenReturn(false); // Call the method under test. emrHelperServiceImpl.emrCreateClusterAwsSpecificSteps(emrClusterCreateRequest, emrClusterDefinition, emrClusterAlternateKeyDto); // Verify the external calls. verify(emrHelper).getAwsParamsDtoByAccountId(emrClusterDefinition.getAccountId()); verify(emrHelper).isInstanceDefinitionsEmpty(emrClusterDefinition.getInstanceDefinitions()); verify(emrPricingHelper).updateEmrClusterDefinitionWithBestPrice(emrClusterAlternateKeyDto, emrClusterDefinition, awsParamsDto); verifyNoMoreInteractionsHelper(); }
/** * Creates a new EMR cluster definition using the specified parameters, updates it with best price algorithm, and returns the definition. * * @param subnetId Subnet ID. Optional. * @param masterInstanceDefinition The master instance definition * @param coreInstanceDefinition The core instance definition * @param taskInstanceDefinition The task instance definition. Optional. * * @return Updated EMR cluster definition. */ private EmrClusterDefinition updateEmrClusterDefinitionWithBestPrice(String subnetId, MasterInstanceDefinition masterInstanceDefinition, InstanceDefinition coreInstanceDefinition, InstanceDefinition taskInstanceDefinition) { EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition(); emrClusterDefinition.setSubnetId(subnetId); InstanceDefinitions instanceDefinitions = new InstanceDefinitions(); instanceDefinitions.setMasterInstances(masterInstanceDefinition); instanceDefinitions.setCoreInstances(coreInstanceDefinition); instanceDefinitions.setTaskInstances(taskInstanceDefinition); emrClusterDefinition.setInstanceDefinitions(instanceDefinitions); emrPricingHelper.updateEmrClusterDefinitionWithBestPrice(new EmrClusterAlternateKeyDto(), emrClusterDefinition, new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, NO_HTTP_PROXY_HOST, NO_HTTP_PROXY_PORT, AWS_REGION_NAME_US_EAST_1)); return emrClusterDefinition; } }