Search in sources :

Example 1 with EmrClusterDefinitionCreateRequest

use of org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest in project herd by FINRAOS.

the class EmrClusterDefinitionRestControllerTest method testCreateEmrClusterDefinition.

@Test
public void testCreateEmrClusterDefinition() throws Exception {
    // Create an EMR cluster definition key.
    EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Create an EMR cluster definition.
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    // Create an EMR cluster definition create request.
    EmrClusterDefinitionCreateRequest emrClusterDefinitionCreateRequest = new EmrClusterDefinitionCreateRequest(emrClusterDefinitionKey, emrClusterDefinition);
    // Create an object that holds EMR cluster definition information.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = new EmrClusterDefinitionInformation(ID, emrClusterDefinitionKey, emrClusterDefinition);
    // Mock the external calls.
    when(emrClusterDefinitionService.createEmrClusterDefinition(emrClusterDefinitionCreateRequest)).thenReturn(emrClusterDefinitionInformation);
    // Call the method under test.
    EmrClusterDefinitionInformation result = emrClusterDefinitionRestController.createEmrClusterDefinition(emrClusterDefinitionCreateRequest);
    // Verify the external calls.
    verify(emrClusterDefinitionService).createEmrClusterDefinition(emrClusterDefinitionCreateRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(emrClusterDefinitionInformation, result);
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 2 with EmrClusterDefinitionCreateRequest

use of org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionCoreInstanceCountNegativeAssertException.

/**
 * Asserts that when a negative number is specified for core instance count, a validation exception is thrown.
 */
@Test
public void testCreateEmrClusterDefinitionCoreInstanceCountNegativeAssertException() throws Exception {
    // Create and persist the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create an EMR cluster definition create request.
    EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition(-1, "m1.medium", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, NO_INSTANCE_SPOT_PRICE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD);
    request.getEmrClusterDefinition().getInstanceDefinitions().setCoreInstances(coreInstanceDefinition);
    // Create an EMR cluster definition.
    try {
        emrClusterDefinitionService.createEmrClusterDefinition(request);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("At least 0 core instance must be specified.", e.getMessage());
    }
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) Test(org.junit.Test)

Example 3 with EmrClusterDefinitionCreateRequest

use of org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinition.

@Test
public void testCreateEmrClusterDefinition() throws Exception {
    // Create and persist the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create an EMR cluster definition create request.
    EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    // Create an EMR cluster definition.
    EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.createEmrClusterDefinition(request);
    // Validate the returned object.
    validateEmrClusterDefinition(null, NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
Also used : EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 4 with EmrClusterDefinitionCreateRequest

use of org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionUpperCaseParameters.

@Test
public void testCreateEmrClusterDefinitionUpperCaseParameters() throws Exception {
    // Create and persist the namespace entity with a lowercase name.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toLowerCase());
    // Create an EMR cluster definition create request by passing the EMR cluster definition name key parameters in upper case.
    EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    // Create an EMR cluster definition.
    EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.createEmrClusterDefinition(request);
    // Validate the returned object.
    validateEmrClusterDefinition(null, NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
Also used : EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 5 with EmrClusterDefinitionCreateRequest

use of org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionLowerCaseParameters.

@Test
public void testCreateEmrClusterDefinitionLowerCaseParameters() throws Exception {
    // Create and persist the namespace entity with an uppercase name.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toUpperCase());
    // Create an EMR cluster definition create request by passing the EMR cluster definition name key parameters in lower case.
    EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    // Create an EMR cluster definition.
    EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.createEmrClusterDefinition(request);
    // Validate the returned object.
    validateEmrClusterDefinition(null, NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
Also used : EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionCreateRequest (org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest)9 Test (org.junit.Test)8 EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)7 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)2 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)2 HashMap (java.util.HashMap)1 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)1