Search in sources :

Example 81 with Attribute

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();
}
Also used : BusinessObjectDataAttributeDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeDefinitionEntity) Attribute(org.finra.herd.model.api.xml.Attribute) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 82 with Attribute

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;
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList)

Example 83 with Attribute

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);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) SchemaColumnEntity(org.finra.herd.model.jpa.SchemaColumnEntity) ArrayList(java.util.ArrayList) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectFormatAttributeEntity(org.finra.herd.model.jpa.BusinessObjectFormatAttributeEntity)

Example 84 with Attribute

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);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList)

Example 85 with Attribute

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);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) Test(org.junit.Test)

Aggregations

Attribute (org.finra.herd.model.api.xml.Attribute)165 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)68 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)34 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)32 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)30 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)28 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)28 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)26 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)23 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)22 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)20 StorageEntity (org.finra.herd.model.jpa.StorageEntity)18 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)16 HashMap (java.util.HashMap)15 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)15 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)15 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)14 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)13 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)12