Search in sources :

Example 11 with EmrClusterDefinitionKey

use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey 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)

Example 12 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinition.

@Test
public void testDeleteEmrClusterDefinition() throws Exception {
    // Create and persist the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create and persist the EMR cluster definition entity.
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    // Validate that this EMR cluster definition exists.
    assertNotNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME));
    executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
        // Delete this EMR cluster definition.
        EmrClusterDefinitionInformation deletedEmrClusterDefinition = emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME));
        // Validate the returned object.
        validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), deletedEmrClusterDefinition);
        // Ensure that this EMR cluster definition is no longer there.
        assertNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME));
    });
}
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 13 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionEmrClusterDefinitionNoExists.

@Test
public void testUpdateEmrClusterDefinitionEmrClusterDefinitionNoExists() throws Exception {
    // Try to perform an update using a non-existing EMR cluster definition name.
    String testEmrClusterDefinitionName = "I_DO_NOT_EXIST";
    try {
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, testEmrClusterDefinitionName), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
        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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 14 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionDuplicateNodeTags.

@Test
public void testUpdateEmrClusterDefinitionDuplicateNodeTags() throws Exception {
    // Try to perform an update by passing duplicate node tag names.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        for (int i = 0; i < 2; i++) {
            NodeTag nodeTag = new NodeTag();
            nodeTag.setTagName(ATTRIBUTE_NAME_1_MIXED_CASE);
            nodeTag.setTagValue(ATTRIBUTE_VALUE_1);
            emrClusterDefinitionConfiguration.getNodeTags().add(nodeTag);
        }
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when duplicate node tag names are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Duplicate node tag \"%s\" is found.", ATTRIBUTE_NAME_1_MIXED_CASE), e.getMessage());
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 15 with EmrClusterDefinitionKey

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

the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionTrimParameters.

@Test
public void testUpdateEmrClusterDefinitionTrimParameters() throws Exception {
    // Create and persist the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create and persist the EMR cluster definition entity using minimal test XML configuration.
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH));
    executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
        // Update an EMR cluster definition with the normal test XML configuration by passing namespace
        // and EMR cluster definition name with leading and trailing whitespace characters.
        EmrClusterDefinitionInformation updatedEmrClusterDefinition = emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(addWhitespace(NAMESPACE), addWhitespace(EMR_CLUSTER_DEFINITION_NAME)), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
        // Validate the returned object.
        validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), updatedEmrClusterDefinition);
    });
}
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

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