Search in sources :

Example 1 with EmrClusterDefinitionInformation

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

the class EmrClusterDefinitionServiceImpl method createEmrClusterDefinitionFromEntity.

/**
 * Creates the EMR cluster definition information from the persisted entity.
 *
 * @param emrClusterDefinitionEntity the EMR cluster definition entity
 *
 * @return the EMR cluster definition information
 */
private EmrClusterDefinitionInformation createEmrClusterDefinitionFromEntity(EmrClusterDefinitionEntity emrClusterDefinitionEntity) throws Exception {
    // Unmarshal EMR cluster definition XML into JAXB object.
    EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, emrClusterDefinitionEntity.getConfiguration());
    // Create a new instance of EMR cluster definition information.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = new EmrClusterDefinitionInformation();
    emrClusterDefinitionInformation.setId(emrClusterDefinitionEntity.getId());
    emrClusterDefinitionInformation.setEmrClusterDefinitionKey(new EmrClusterDefinitionKey(emrClusterDefinitionEntity.getNamespace().getCode(), emrClusterDefinitionEntity.getName()));
    emrClusterDefinitionInformation.setEmrClusterDefinition(emrClusterDefinition);
    return emrClusterDefinitionInformation;
}
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)

Example 2 with EmrClusterDefinitionInformation

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInformation 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 3 with EmrClusterDefinitionInformation

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInformation 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);
}
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 4 with EmrClusterDefinitionInformation

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInformation 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);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Example 5 with EmrClusterDefinitionInformation

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

the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinitionLowerCaseParameters.

@Test
public void testDeleteEmrClusterDefinitionLowerCaseParameters() 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));
    // Validate that this EMR cluster definition exists.
    assertNotNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase()));
    executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
        // Delete this EMR cluster definition by passing the EMR cluster definition name key parameters in lower case.
        EmrClusterDefinitionInformation deletedEmrClusterDefinition = emrClusterDefinitionService.deleteEmrClusterDefinition(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), deletedEmrClusterDefinition);
        // Ensure that this EMR cluster definition is no longer there.
        assertNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase()));
    });
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)23 Test (org.junit.Test)22 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)17 EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)12 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)12 EmrClusterDefinitionCreateRequest (org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest)7 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)5 EmrClusterDefinitionUpdateRequest (org.finra.herd.model.api.xml.EmrClusterDefinitionUpdateRequest)2 HashMap (java.util.HashMap)1 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)1