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());
}
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations