Search in sources :

Example 21 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionMissingRequiredParameters.

@Test
public void testGetEmrClusterDefinitionMissingRequiredParameters() throws Exception {
    // Try to perform a get without specifying a namespace.
    try {
        emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(BLANK_TEXT, EMR_CLUSTER_DEFINITION_NAME));
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to perform a get without specifying an EMR cluster definition name.
    try {
        emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, BLANK_TEXT));
        fail("Should throw an IllegalArgumentException when EMR cluster definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An EMR cluster definition name must be specified.", e.getMessage());
    }
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 22 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionRestControllerTest method testUpdateEmrClusterDefinition.

@Test
public void testUpdateEmrClusterDefinition() 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 update request.
    EmrClusterDefinitionUpdateRequest emrClusterDefinitionUpdateRequest = new EmrClusterDefinitionUpdateRequest(emrClusterDefinition);
    // Create an object that holds EMR cluster definition information.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = new EmrClusterDefinitionInformation(ID, emrClusterDefinitionKey, emrClusterDefinition);
    // Mock the external calls.
    when(emrClusterDefinitionService.updateEmrClusterDefinition(emrClusterDefinitionKey, emrClusterDefinitionUpdateRequest)).thenReturn(emrClusterDefinitionInformation);
    // Call the method under test.
    EmrClusterDefinitionInformation result = emrClusterDefinitionRestController.updateEmrClusterDefinition(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionUpdateRequest);
    // Verify the external calls.
    verify(emrClusterDefinitionService).updateEmrClusterDefinition(emrClusterDefinitionKey, emrClusterDefinitionUpdateRequest);
    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) EmrClusterDefinitionUpdateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionUpdateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 23 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionRestControllerTest method testGetEmrClusterDefinition.

@Test
public void testGetEmrClusterDefinition() 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 object that holds EMR cluster definition information.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = new EmrClusterDefinitionInformation(ID, emrClusterDefinitionKey, emrClusterDefinition);
    // Mock the external calls.
    when(emrClusterDefinitionService.getEmrClusterDefinition(emrClusterDefinitionKey)).thenReturn(emrClusterDefinitionInformation);
    // Call the method under test.
    EmrClusterDefinitionInformation result = emrClusterDefinitionRestController.getEmrClusterDefinition(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Verify the external calls.
    verify(emrClusterDefinitionService).getEmrClusterDefinition(emrClusterDefinitionKey);
    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) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 24 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionRestControllerTest method testGetEmrClusterDefinitions.

@Test
public void testGetEmrClusterDefinitions() throws Exception {
    // Create an EMR cluster definition keys.
    EmrClusterDefinitionKeys emrClusterDefinitionKeys = new EmrClusterDefinitionKeys(Arrays.asList(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME)));
    // Mock the external calls.
    when(emrClusterDefinitionService.getEmrClusterDefinitions(NAMESPACE)).thenReturn(emrClusterDefinitionKeys);
    // Call the method under test.
    EmrClusterDefinitionKeys result = emrClusterDefinitionRestController.getEmrClusterDefinitions(NAMESPACE);
    // Verify the external calls.
    verify(emrClusterDefinitionService).getEmrClusterDefinitions(NAMESPACE);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(emrClusterDefinitionKeys, result);
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionKeys(org.finra.herd.model.api.xml.EmrClusterDefinitionKeys) Test(org.junit.Test)

Example 25 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionMissingMandatoryNodeTags.

@Test
public void testUpdateEmrClusterDefinitionMissingMandatoryNodeTags() throws Exception {
    // Set a list of test mandatory AWS tags that are present in EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH XML file.
    List<String> testMandatoryAwsTagNames = Arrays.asList(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_NAME_3_MIXED_CASE);
    // Override configuration to add max partition values.
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.MANDATORY_AWS_TAGS.getKey(), StringUtils.join(testMandatoryAwsTagNames, "|"));
    modifyPropertySourceInEnvironment(overrideMap);
    try {
        // Test each of the AWS mandatory node tags.
        for (String mandatoryAwsTagName : testMandatoryAwsTagNames) {
            EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
            // Change EMR cluster definition configuration to have a new list of the test node tags that does not have the relative AWS mandatory node tag.
            emrClusterDefinitionConfiguration.setNodeTags(getTestNodeTags(testMandatoryAwsTagNames, mandatoryAwsTagName));
            try {
                emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
                fail(String.format("Should throw an IllegalArgumentException when \"%s\" required AWS node tag is not specified.", mandatoryAwsTagName));
            } catch (IllegalArgumentException e) {
                assertEquals(String.format("Mandatory AWS tag not specified: \"%s\"", mandatoryAwsTagName), e.getMessage());
            }
        }
    } finally {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) HashMap(java.util.HashMap) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)35 Test (org.junit.Test)32 EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)17 EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)14 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)13 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)9 EmrClusterDefinitionKeys (org.finra.herd.model.api.xml.EmrClusterDefinitionKeys)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 HashMap (java.util.HashMap)2 EmrClusterDefinitionCreateRequest (org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest)2 EmrClusterDefinitionUpdateRequest (org.finra.herd.model.api.xml.EmrClusterDefinitionUpdateRequest)2 NodeTag (org.finra.herd.model.api.xml.NodeTag)2 ArrayList (java.util.ArrayList)1 Tuple (javax.persistence.Tuple)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1