Search in sources :

Example 46 with BusinessObjectData

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

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataBothFormatAndDataVersionsNotSpecified.

/**
 * This test validates business object data get when both business object format and data versions are not specified.
 */
@Test
public void testGetBusinessObjectDataBothFormatAndDataVersionsNotSpecified() {
    // Create business object data status entities.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2);
    // Create business object format entities.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, NO_LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    // Create business object data entities for the initial format version.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, THIRD_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Create business object data entities for the second format version.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    BusinessObjectData resultBusinessObjectData;
    // Retrieve a business object data without specifying business object format version, business object data version, and business object data status.
    resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Validate the returned object, it should be the latest VALID business object format and data version available.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, resultBusinessObjectData);
    // Retrieve a business object data by explicitly specifying VALID business object data status.
    resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), PARTITION_KEY, BusinessObjectDataStatusEntity.VALID, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Validate the returned object, it should be the latest VALID business object format and data version available.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, resultBusinessObjectData);
    // Retrieve a business object data by explicitly specifying business object data status testing value.
    resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), PARTITION_KEY, BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Validate the returned object, it should be the latest business object format and data version with the test business object data status.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, resultBusinessObjectData);
    // Try to retrieve a business object data by explicitly specifying an incorrect business object data status value.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), PARTITION_KEY, BDATA_STATUS_2, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when business object data does not exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION, BDATA_STATUS_2), e.getMessage());
    }
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 47 with BusinessObjectData

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

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataUsingCreateRequest.

@Test
public void testGetBusinessObjectDataUsingCreateRequest() {
    BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();
    StorageUnitCreateRequest storageUnit = request.getStorageUnits().get(0);
    // Create the business object data.
    businessObjectDataService.createBusinessObjectData(request);
    // Retrieve the business object data.
    BusinessObjectData businessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion(), request.getPartitionValue(), request.getSubPartitionValues(), INITIAL_DATA_VERSION), request.getPartitionKey(), NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Verify the results.
    assertNotNull(businessObjectData);
    assertNotNull(businessObjectData.getId());
    assertTrue(businessObjectData.getBusinessObjectDefinitionName().equals(request.getBusinessObjectDefinitionName()));
    assertTrue(businessObjectData.getBusinessObjectFormatUsage().equals(request.getBusinessObjectFormatUsage()));
    assertTrue(businessObjectData.getBusinessObjectFormatFileType().equals(request.getBusinessObjectFormatFileType()));
    assertTrue(businessObjectData.getBusinessObjectFormatVersion() == request.getBusinessObjectFormatVersion());
    assertTrue(businessObjectData.getPartitionValue().equals(request.getPartitionValue()));
    assertTrue(businessObjectData.getSubPartitionValues().equals(request.getSubPartitionValues()));
    assertTrue(businessObjectData.getVersion() == INITIAL_DATA_VERSION);
    assertTrue(businessObjectData.isLatestVersion());
    List<StorageUnit> storageUnits = businessObjectData.getStorageUnits();
    assertTrue(storageUnits.size() == 1);
    StorageUnit resultStorageUnit = storageUnits.get(0);
    assertTrue(resultStorageUnit.getStorage().getName().equals(storageUnit.getStorageName()));
    // Check if result storage directory path matches to the directory path from the request.
    assertEquals(storageUnit.getStorageDirectory(), resultStorageUnit.getStorageDirectory());
    // Check if result list of storage files matches to the list from the create request.
    businessObjectDataServiceTestHelper.validateStorageFiles(resultStorageUnit.getStorageFiles(), storageUnit.getStorageFiles());
    // Check if result list of attributes matches to the list from the create request.
    businessObjectDefinitionServiceTestHelper.validateAttributes(request.getAttributes(), businessObjectData.getAttributes());
    // Validate the parents.
    assertTrue(businessObjectData.getBusinessObjectDataParents().size() == 2);
    Collections.sort(request.getBusinessObjectDataParents(), new BusinessObjectDataKeyComparator());
    assertEquals(request.getBusinessObjectDataParents(), businessObjectData.getBusinessObjectDataParents());
    // Ensure no children exist since the entity is new.
    assertTrue(businessObjectData.getBusinessObjectDataChildren().size() == 0);
    // Get one of the parents.
    BusinessObjectDataKey businessObjectDataParentKey = request.getBusinessObjectDataParents().get(0);
    // Retrieve the business object data for the parent.
    BusinessObjectData businessObjectDataParent = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(businessObjectDataParentKey.getNamespace(), businessObjectDataParentKey.getBusinessObjectDefinitionName(), businessObjectDataParentKey.getBusinessObjectFormatUsage(), businessObjectDataParentKey.getBusinessObjectFormatFileType(), businessObjectDataParentKey.getBusinessObjectFormatVersion(), businessObjectDataParentKey.getPartitionValue(), businessObjectDataParentKey.getSubPartitionValues(), businessObjectDataParentKey.getBusinessObjectDataVersion()), request.getPartitionKey(), NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Ensure that the parent contains a single child record and that it is equal to our original business object data we created.
    assertTrue(businessObjectDataParent.getBusinessObjectDataChildren().size() == 1);
    assertEquals(businessObjectDataHelper.createBusinessObjectDataKey(businessObjectData), businessObjectDataParent.getBusinessObjectDataChildren().get(0));
}
Also used : BusinessObjectDataKeyComparator(org.finra.herd.service.helper.BusinessObjectDataKeyComparator) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) StorageUnitCreateRequest(org.finra.herd.model.api.xml.StorageUnitCreateRequest) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 48 with BusinessObjectData

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

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataTrimParameters.

@Test
public void testGetBusinessObjectDataTrimParameters() {
    // Create and persist a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    // Retrieve the business object data using input parameters with leading and trailing empty spaces.
    // Please note that we do not specify business object data version in order for the business object data status to have an effect.
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(SUBPARTITION_VALUES), NO_DATA_VERSION), addWhitespace(PARTITION_KEY), addWhitespace(BDATA_STATUS), NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS, resultBusinessObjectData);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 49 with BusinessObjectData

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

the class BusinessObjectDataServiceRestoreBusinessObjectDataTest method testRestoreBusinessObjectDataNonGlacierStorageClass.

@Test
public void testRestoreBusinessObjectDataNonGlacierStorageClass() throws Exception {
    // Create S3FileTransferRequestParamsDto to access the S3 bucket.
    // Since test S3 key prefix represents a directory, we add a trailing '/' character to it.
    S3FileTransferRequestParamsDto glacierS3FileTransferRequestParamsDto = S3FileTransferRequestParamsDto.builder().withS3BucketName(S3_BUCKET_NAME).withS3KeyPrefix(S3_BUCKET_NAME + "/" + TEST_S3_KEY_PREFIX + "/").build();
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create database entities required for testing.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createDatabaseEntitiesForInitiateRestoreTesting(businessObjectDataKey);
    // Get the storage unit entity.
    StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity);
    try {
        // Put relative non-Glacier storage class files into the S3 bucket.
        for (StorageFileEntity storageFileEntity : storageUnitEntity.getStorageFiles()) {
            ObjectMetadata metadata = new ObjectMetadata();
            metadata.setHeader(Headers.STORAGE_CLASS, StorageClass.Standard);
            metadata.setOngoingRestore(false);
            s3Operations.putObject(new PutObjectRequest(S3_BUCKET_NAME, storageFileEntity.getPath(), new ByteArrayInputStream(new byte[storageFileEntity.getFileSizeBytes().intValue()]), metadata), NO_S3_CLIENT);
        }
        // Initiate a restore request for the business object data.
        BusinessObjectData businessObjectData = businessObjectDataService.restoreBusinessObjectData(businessObjectDataKey, EXPIRATION_IN_DAYS);
        // Validate the returned object.
        businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS, businessObjectData);
        // Validate that the origin storage unit status is RESTORING.
        assertEquals(StorageUnitStatusEntity.RESTORING, storageUnitEntity.getStatus().getCode());
        // Validate that there is still no ongoing restore request for all non-Glacier objects.
        for (StorageFileEntity storageFileEntity : storageUnitEntity.getStorageFiles()) {
            ObjectMetadata objectMetadata = s3Operations.getObjectMetadata(S3_BUCKET_NAME, storageFileEntity.getPath(), NO_S3_CLIENT);
            assertFalse(objectMetadata.getOngoingRestore());
        }
    } finally {
        // Delete test files from S3 storage.
        if (!s3Dao.listDirectory(glacierS3FileTransferRequestParamsDto).isEmpty()) {
            s3Dao.deleteDirectory(glacierS3FileTransferRequestParamsDto);
        }
        s3Operations.rollback();
    }
}
Also used : StorageFileEntity(org.finra.herd.model.jpa.StorageFileEntity) S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) ByteArrayInputStream(java.io.ByteArrayInputStream) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) PutObjectRequest(com.amazonaws.services.s3.model.PutObjectRequest) Test(org.junit.Test)

Example 50 with BusinessObjectData

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

the class RelationalTableRegistrationServiceTest method testCreateRelationalTableRegistration.

@Test
public void testCreateRelationalTableRegistration() {
    // Create database entities required for relational table registration testing.
    relationalTableRegistrationServiceTestHelper.createDatabaseEntitiesForRelationalTableRegistrationTesting(BDEF_NAMESPACE, DATA_PROVIDER_NAME, STORAGE_NAME);
    // Pick one of the in-memory database tables to be registered as a relational table.
    String relationalSchemaName = "PUBLIC";
    String relationalTableName = BusinessObjectDefinitionEntity.TABLE_NAME.toUpperCase();
    // Create a relational table registration create request for a table that is part of the in-memory database setup as part of DAO mocks.
    RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest = new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, relationalSchemaName, relationalTableName, STORAGE_NAME);
    // Create a relational table registration.
    BusinessObjectData businessObjectData = relationalTableRegistrationService.createRelationalTableRegistration(relationalTableRegistrationCreateRequest, APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
    // Create an expected storage unit.
    StorageUnit expectedStorageUnit = new StorageUnit();
    expectedStorageUnit.setStorage(new Storage(STORAGE_NAME, StoragePlatformEntity.RELATIONAL, relationalTableRegistrationServiceTestHelper.getStorageAttributes()));
    expectedStorageUnit.setStorageUnitStatus(StorageUnitStatusEntity.ENABLED);
    // Create an expected business object data.
    BusinessObjectData expectedBusinessObjectData = new BusinessObjectData();
    expectedBusinessObjectData.setId(businessObjectData.getId());
    expectedBusinessObjectData.setNamespace(BDEF_NAMESPACE);
    expectedBusinessObjectData.setBusinessObjectDefinitionName(BDEF_NAME);
    expectedBusinessObjectData.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    expectedBusinessObjectData.setBusinessObjectFormatFileType(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE);
    expectedBusinessObjectData.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION);
    expectedBusinessObjectData.setPartitionValue(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_VALUE);
    expectedBusinessObjectData.setSubPartitionValues(new ArrayList<>());
    expectedBusinessObjectData.setVersion(INITIAL_DATA_VERSION);
    expectedBusinessObjectData.setPartitionKey(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_KEY);
    expectedBusinessObjectData.setLatestVersion(LATEST_VERSION_FLAG_SET);
    expectedBusinessObjectData.setStatus(BusinessObjectDataStatusEntity.VALID);
    expectedBusinessObjectData.setStorageUnits(Collections.singletonList(expectedStorageUnit));
    expectedBusinessObjectData.setAttributes(new ArrayList<>());
    expectedBusinessObjectData.setBusinessObjectDataParents(new ArrayList<>());
    expectedBusinessObjectData.setBusinessObjectDataChildren(new ArrayList<>());
    // Validate the response.
    assertEquals(expectedBusinessObjectData, businessObjectData);
    // Create a business object format key.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, INITIAL_FORMAT_VERSION);
    // Retrieve business object format that was created as part of the relational table registration.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.getBusinessObjectFormat(businessObjectFormatKey);
    // Create an expected schema.
    Schema expectedSchema = new Schema();
    expectedSchema.setColumns(relationalTableRegistrationServiceTestHelper.getExpectedSchemaColumns());
    expectedSchema.setNullValue(EMPTY_STRING);
    // Build an expected business object format.
    BusinessObjectFormat expectedBusinessObjectFormat = new BusinessObjectFormat();
    expectedBusinessObjectFormat.setId(businessObjectFormat.getId());
    expectedBusinessObjectFormat.setNamespace(BDEF_NAMESPACE);
    expectedBusinessObjectFormat.setBusinessObjectDefinitionName(BDEF_NAME);
    expectedBusinessObjectFormat.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    expectedBusinessObjectFormat.setBusinessObjectFormatFileType(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE);
    expectedBusinessObjectFormat.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION);
    expectedBusinessObjectFormat.setLatestVersion(LATEST_VERSION_FLAG_SET);
    expectedBusinessObjectFormat.setPartitionKey(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_KEY);
    expectedBusinessObjectFormat.setBusinessObjectFormatParents(new ArrayList<>());
    expectedBusinessObjectFormat.setBusinessObjectFormatChildren(new ArrayList<>());
    expectedBusinessObjectFormat.setAttributeDefinitions(new ArrayList<>());
    expectedBusinessObjectFormat.setAttributes(Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_FORMAT_ATTRIBUTE_NAME_RELATIONAL_SCHEMA_NAME), relationalSchemaName), new Attribute(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_FORMAT_ATTRIBUTE_NAME_RELATIONAL_TABLE_NAME), relationalTableName)));
    expectedBusinessObjectFormat.setSchema(expectedSchema);
    // Validate the newly created business object format.
    assertEquals(expectedBusinessObjectFormat, businessObjectFormat);
    // Create a business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
    // Retrieve business object definition that was created as part of the relational table registration.
    BusinessObjectDefinition businessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, true);
    // Create an expected business object definition.
    BusinessObjectDefinition expectedBusinessObjectDefinition = new BusinessObjectDefinition();
    expectedBusinessObjectDefinition.setId(businessObjectDefinition.getId());
    expectedBusinessObjectDefinition.setNamespace(BDEF_NAMESPACE);
    expectedBusinessObjectDefinition.setBusinessObjectDefinitionName(BDEF_NAME);
    expectedBusinessObjectDefinition.setDataProviderName(DATA_PROVIDER_NAME);
    expectedBusinessObjectDefinition.setDisplayName(BDEF_DISPLAY_NAME);
    expectedBusinessObjectDefinition.setAttributes(new ArrayList<>());
    expectedBusinessObjectDefinition.setSampleDataFiles(new ArrayList<>());
    expectedBusinessObjectDefinition.setCreatedByUserId(businessObjectDefinition.getCreatedByUserId());
    expectedBusinessObjectDefinition.setLastUpdatedByUserId(businessObjectDefinition.getLastUpdatedByUserId());
    expectedBusinessObjectDefinition.setLastUpdatedOn(businessObjectDefinition.getLastUpdatedOn());
    expectedBusinessObjectDefinition.setBusinessObjectDefinitionChangeEvents(businessObjectDefinition.getBusinessObjectDefinitionChangeEvents());
    // Validate the newly created business object definition.
    assertEquals(expectedBusinessObjectDefinition, businessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) Storage(org.finra.herd.model.api.xml.Storage) RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Schema(org.finra.herd.model.api.xml.Schema) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Aggregations

BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)150 Test (org.junit.Test)121 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)64 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)57 ArrayList (java.util.ArrayList)39 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)29 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)25 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)19 Storage (org.finra.herd.model.api.xml.Storage)19 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 Attribute (org.finra.herd.model.api.xml.Attribute)15 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)14 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)12 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)11 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)9 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)8 UploaderInputManifestDto (org.finra.herd.model.dto.UploaderInputManifestDto)8 IOException (java.io.IOException)7 BusinessObjectDataRetryStoragePolicyTransitionRequest (org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest)7 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)7