use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class AttributeDaoHelperTest method testValidateAttributesAgainstBusinessObjectDataAttributeDefinitionsAttributeNamesEqualIgnoreCase.
@Test
public void testValidateAttributesAgainstBusinessObjectDataAttributeDefinitionsAttributeNamesEqualIgnoreCase() {
// Create a business object data attribute definition for a required attribute with attribute name in upper case.
BusinessObjectDataAttributeDefinitionEntity businessObjectDataAttributeDefinitionEntity = new BusinessObjectDataAttributeDefinitionEntity();
businessObjectDataAttributeDefinitionEntity.setName(ATTRIBUTE_NAME.toUpperCase());
// Call the method under test with the attribute name specified in lowercase.
attributeDaoHelper.validateAttributesAgainstBusinessObjectDataAttributeDefinitions(Arrays.asList(new Attribute(ATTRIBUTE_NAME.toLowerCase(), ATTRIBUTE_VALUE)), Arrays.asList(businessObjectDataAttributeDefinitionEntity));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method getNewStorage.
/**
* Gets a new storage object with the specified information.
*
* @param storageName the storage name.
*
* @return the newly created storage.
*/
private Storage getNewStorage(String storageName) {
Storage storage = new Storage();
storage.setName(storageName);
storage.setStoragePlatformName(StoragePlatformEntity.S3);
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket"));
/*
* Set the KMS key attribute if the storage name contains ignore case the word "KMS" (ex. S3_MANAGED_KMS)
*/
if (storageName.toLowerCase().contains("kms")) {
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "testKmsKeyId"));
}
storage.setAttributes(attributes);
return storage;
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class BusinessObjectFormatDaoTestHelper method createBusinessObjectFormatEntity.
/**
* Creates and persists a new business object format entity.
*
* @return the newly created business object format entity.
*/
public BusinessObjectFormatEntity createBusinessObjectFormatEntity(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String businessObjectFormatUsage, FileTypeEntity fileTypeEntity, Integer businessObjectFormatVersion, String businessObjectFormatDescription, Boolean businessObjectFormatLatestVersion, String businessObjectFormatPartitionKey, PartitionKeyGroupEntity partitionKeyGroupEntity, List<Attribute> attributes, String schemaDelimiterCharacter, String schemaEscapeCharacter, String schemaNullValue, List<SchemaColumn> schemaColumns, List<SchemaColumn> partitionColumns) {
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
businessObjectFormatEntity.setDescription(businessObjectFormatDescription);
businessObjectFormatEntity.setFileType(fileTypeEntity);
businessObjectFormatEntity.setBusinessObjectFormatVersion(businessObjectFormatVersion);
businessObjectFormatEntity.setLatestVersion(businessObjectFormatLatestVersion);
businessObjectFormatEntity.setUsage(businessObjectFormatUsage);
businessObjectFormatEntity.setPartitionKey(businessObjectFormatPartitionKey);
businessObjectFormatEntity.setPartitionKeyGroup(partitionKeyGroupEntity);
// Create the attributes if they are specified.
if (!CollectionUtils.isEmpty(attributes)) {
List<BusinessObjectFormatAttributeEntity> attributeEntities = new ArrayList<>();
businessObjectFormatEntity.setAttributes(attributeEntities);
for (Attribute attribute : attributes) {
BusinessObjectFormatAttributeEntity attributeEntity = new BusinessObjectFormatAttributeEntity();
attributeEntities.add(attributeEntity);
attributeEntity.setBusinessObjectFormat(businessObjectFormatEntity);
attributeEntity.setName(attribute.getName());
attributeEntity.setValue(attribute.getValue());
}
}
if (schemaColumns != null && !schemaColumns.isEmpty()) {
businessObjectFormatEntity.setDelimiter(schemaDelimiterCharacter);
businessObjectFormatEntity.setEscapeCharacter(schemaEscapeCharacter);
businessObjectFormatEntity.setNullValue(schemaNullValue);
List<SchemaColumnEntity> schemaColumnEntities = new ArrayList<>();
businessObjectFormatEntity.setSchemaColumns(schemaColumnEntities);
int columnPosition = 1;
for (SchemaColumn schemaColumn : schemaColumns) {
SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
schemaColumnEntities.add(schemaColumnEntity);
schemaColumnEntity.setBusinessObjectFormat(businessObjectFormatEntity);
schemaColumnEntity.setPosition(columnPosition);
schemaColumnEntity.setPartitionLevel(null);
schemaColumnEntity.setName(schemaColumn.getName());
schemaColumnEntity.setType(schemaColumn.getType());
schemaColumnEntity.setSize(schemaColumn.getSize());
schemaColumnEntity.setDescription(schemaColumn.getDescription());
schemaColumnEntity.setRequired(schemaColumn.isRequired());
schemaColumnEntity.setDefaultValue(schemaColumn.getDefaultValue());
columnPosition++;
}
if (partitionColumns != null && !partitionColumns.isEmpty()) {
int partitionLevel = 1;
for (SchemaColumn schemaColumn : partitionColumns) {
// Check if this partition column belongs to the list of regular schema columns.
int schemaColumnIndex = schemaColumns.indexOf(schemaColumn);
if (schemaColumnIndex >= 0) {
// Retrieve the relative column entity and set its partition level.
schemaColumnEntities.get(schemaColumnIndex).setPartitionLevel(partitionLevel);
} else {
// Add this partition column as a new schema column entity.
SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
schemaColumnEntities.add(schemaColumnEntity);
schemaColumnEntity.setBusinessObjectFormat(businessObjectFormatEntity);
schemaColumnEntity.setPosition(null);
schemaColumnEntity.setPartitionLevel(partitionLevel);
schemaColumnEntity.setName(schemaColumn.getName());
schemaColumnEntity.setType(schemaColumn.getType());
schemaColumnEntity.setSize(schemaColumn.getSize());
schemaColumnEntity.setDescription(schemaColumn.getDescription());
schemaColumnEntity.setRequired(schemaColumn.isRequired());
schemaColumnEntity.setDefaultValue(schemaColumn.getDefaultValue());
}
partitionLevel++;
}
}
}
return businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class StorageDaoTestHelper method createStorageEntity.
/**
* Creates and persists a new storage entity with an attribute.
*
* @param storageName the storage name
* @param storagePlatformCode the storage platform code
* @param attributeName the attribute name
* @param attributeValue the attribute value
*
* @return the newly created storage entity.
*/
public StorageEntity createStorageEntity(String storageName, String storagePlatformCode, String attributeName, String attributeValue) {
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(attributeName, attributeValue));
return createStorageEntity(storageName, storagePlatformCode, attributes);
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class BusinessObjectDefinitionRestControllerTest method testGetBusinessObjectDefinitionNotIncludeUpdateHistory.
@Test
public void testGetBusinessObjectDefinitionNotIncludeUpdateHistory() {
// Create a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create a business object definition.
BusinessObjectDefinition businessObjectDefinition = new BusinessObjectDefinition(ID, BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1)), new DescriptiveBusinessObjectFormat(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), Arrays.asList(new SampleDataFile(DIRECTORY_PATH, FILE_NAME)), CREATED_BY, UPDATED_BY, UPDATED_ON, NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS);
// Mock the external calls.
when(businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY)).thenReturn(businessObjectDefinition);
// Call the method under test.
BusinessObjectDefinition result = businessObjectDefinitionRestController.getBusinessObjectDefinition(BDEF_NAMESPACE, BDEF_NAME, NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
// Verify the external calls.
verify(businessObjectDefinitionService).getBusinessObjectDefinition(businessObjectDefinitionKey, NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
verifyNoMoreInteractions(businessObjectDefinitionService);
// Validate the results.
assertEquals(businessObjectDefinition, result);
}
Aggregations