use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionRestControllerTest method testDeleteEmrClusterDefinition.
@Test
public void testDeleteEmrClusterDefinition() 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.deleteEmrClusterDefinition(emrClusterDefinitionKey)).thenReturn(emrClusterDefinitionInformation);
// Call the method under test.
EmrClusterDefinitionInformation result = emrClusterDefinitionRestController.deleteEmrClusterDefinition(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
// Verify the external calls.
verify(emrClusterDefinitionService).deleteEmrClusterDefinition(emrClusterDefinitionKey);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(emrClusterDefinitionInformation, result);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionsLowerCaseParameters.
@Test
public void testGetEmrClusterDefinitionsLowerCaseParameters() throws Exception {
// Create and persist an EMR cluster definition entity.
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
// Create an EMR cluster definition key.
EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
// Retrieve EMR cluster definition keys by passing namespace parameter value in lowercase.
assertEquals(new EmrClusterDefinitionKeys(Arrays.asList(emrClusterDefinitionKey)), emrClusterDefinitionService.getEmrClusterDefinitions(NAMESPACE.toLowerCase()));
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinitionEmrClusterDefinitionNoExists.
@Test
public void testDeleteEmrClusterDefinitionEmrClusterDefinitionNoExists() throws Exception {
// Try to perform a delete using a non-existing EMR cluster definition name.
String testEmrClusterDefinitionName = "I_DO_NOT_EXIST";
try {
emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, testEmrClusterDefinitionName));
fail("Should throw an ObjectNotFoundException when EMR cluster definition does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("EMR cluster definition with name \"%s\" doesn't exist for namespace \"%s\".", testEmrClusterDefinitionName, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionLowerCaseParameters.
@Test
public void testGetEmrClusterDefinitionLowerCaseParameters() throws Exception {
// Create and persist the namespace entity with an uppercase name.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toUpperCase());
// Create and persist the EMR cluster definition entity with an uppercase name.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Get an EMR cluster definition by passing the EMR cluster definition name key parameters in lower case.
EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase()));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionsUpperCaseParameters.
@Test
public void testGetEmrClusterDefinitionsUpperCaseParameters() throws Exception {
// Create and persist an EMR cluster definition entity.
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
// Create an EMR cluster definition key.
EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
// Retrieve EMR cluster definition keys by passing namespace parameter value in uppercase.
assertEquals(new EmrClusterDefinitionKeys(Arrays.asList(emrClusterDefinitionKey)), emrClusterDefinitionService.getEmrClusterDefinitions(NAMESPACE.toUpperCase()));
}
Aggregations