use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterAmazonObjectNotFound.
/**
* This method tests the error cases for AmazonExceptions for Illegal Argument
*/
@Test(expected = ObjectNotFoundException.class)
public void testCreateEmrClusterAmazonObjectNotFound() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(MockAwsOperationsHelper.AMAZON_NOT_FOUND);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterSecurityConfigurationNoReleaseLabel.
@Test
public void testCreateEmrClusterSecurityConfigurationNoReleaseLabel() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
// Set the security configuration without an EMR release label.
emrClusterDefinition.setSecurityConfiguration("securityConfiguration");
emrClusterDefinition.setReleaseLabel(BLANK_TEXT);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Try to create a new EMR cluster.
try {
emrService.createCluster(getNewEmrClusterCreateRequest());
} catch (IllegalArgumentException e) {
assertEquals("EMR security configuration is not supported prior to EMR release 4.8.0.", e.getMessage());
}
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class BusinessObjectFormatServiceTestHelper method createBusinessObjectFormat.
/**
* Creates and persists {@link org.finra.herd.model.jpa.BusinessObjectFormatEntity} from the given request. Also creates and persists namespace, data
* provider, bdef, and file type required for the format. If the request has sub-partitions, schema columns will be persisted. Otherwise, no schema will be
* set for this format.
*
* @param request {@link org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest} format alt key
*
* @return created {@link org.finra.herd.model.jpa.BusinessObjectFormatEntity}
*/
public BusinessObjectFormatEntity createBusinessObjectFormat(BusinessObjectDataInvalidateUnregisteredRequest request) {
// Create namespace
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(request.getNamespace());
// Create data provider with a name which is irrelevant for the test cases
DataProviderEntity dataProviderEntity = dataProviderDaoTestHelper.createDataProviderEntity(AbstractServiceTest.DATA_PROVIDER_NAME);
// Create business object definition
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(namespaceEntity, request.getBusinessObjectDefinitionName(), dataProviderEntity, AbstractServiceTest.NO_BDEF_DESCRIPTION, AbstractServiceTest.NO_BDEF_DISPLAY_NAME, AbstractServiceTest.NO_ATTRIBUTES, AbstractServiceTest.NO_SAMPLE_DATA_FILES);
// Create file type
FileTypeEntity fileTypeEntity = fileTypeDaoTestHelper.createFileTypeEntity(request.getBusinessObjectFormatFileType());
// Manually creating format since it is easier than providing large amounts of params to existing method
// Create format
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
businessObjectFormatEntity.setUsage(request.getBusinessObjectFormatUsage());
businessObjectFormatEntity.setFileType(fileTypeEntity);
businessObjectFormatEntity.setBusinessObjectFormatVersion(request.getBusinessObjectFormatVersion());
// If sub-partition values exist in the request
if (!CollectionUtils.isEmpty(request.getSubPartitionValues())) {
// Create schema columns
List<SchemaColumnEntity> schemaColumnEntities = new ArrayList<>();
for (int partitionLevel = 0; partitionLevel < request.getSubPartitionValues().size() + 1; partitionLevel++) {
SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
schemaColumnEntity.setBusinessObjectFormat(businessObjectFormatEntity);
schemaColumnEntity.setName(AbstractServiceTest.PARTITION_KEY + partitionLevel);
schemaColumnEntity.setType("STRING");
schemaColumnEntity.setPartitionLevel(partitionLevel);
schemaColumnEntity.setPosition(partitionLevel);
schemaColumnEntities.add(schemaColumnEntity);
}
businessObjectFormatEntity.setSchemaColumns(schemaColumnEntities);
businessObjectFormatEntity.setPartitionKey(AbstractServiceTest.PARTITION_KEY + "0");
} else // If sub-partition values do not exist in the request
{
businessObjectFormatEntity.setPartitionKey(AbstractServiceTest.PARTITION_KEY);
}
businessObjectFormatEntity.setLatestVersion(true);
businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
return businessObjectFormatEntity;
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterMandatoryTagsNull.
/**
* This method tests the scenario where task instances are there
*/
@Test
public void testCreateEmrClusterMandatoryTagsNull() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
// Remove property source so that we can test mandatory tags config being null
Map<String, Object> overrideMap = new HashMap<>();
overrideMap.put(ConfigurationValue.MANDATORY_AWS_TAGS.getKey(), null);
modifyPropertySourceInEnvironment(overrideMap);
EmrCluster emrCluster = emrService.createCluster(request);
// Validate the returned object against the input.
assertNotNull(emrCluster);
assertTrue(emrCluster.getNamespace().equals(request.getNamespace()));
assertTrue(emrCluster.getEmrClusterDefinitionName().equals(request.getEmrClusterDefinitionName()));
assertTrue(emrCluster.getEmrClusterName().equals(request.getEmrClusterName()));
restorePropertySourceInEnvironment();
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testGetEmrClusterByIdDoesNotExist.
/**
* This method tests the scenario when cluster specified does not exists.
*/
@Test(expected = IllegalArgumentException.class)
public void testGetEmrClusterByIdDoesNotExist() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = EmrClusterAlternateKeyDto.builder().withNamespace(NAMESPACE).withEmrClusterDefinitionName(EMR_CLUSTER_DEFINITION_NAME).withEmrClusterName("cluster_does_not_exist").build();
emrService.getCluster(emrClusterAlternateKeyDto, "cluster_does_not_exist", null, true, null, false);
fail("Should throw an IllegalArgumentException.");
}
Aggregations