Search in sources :

Example 61 with BusinessObjectFormatKey

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

the class BusinessObjectDataServiceGetAllBusinessObjectDataTest method testGetAllBusinessObjectDataByBusinessObjectFormat.

@Test
public void testGetAllBusinessObjectDataByBusinessObjectFormat() {
    // Create a business object definition key.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION);
    // Create a business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectFormatKey, FORMAT_DESCRIPTION, NO_LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    // Create a list of business object data keys.
    List<BusinessObjectDataKey> businessObjectDataKeys = Arrays.asList(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION));
    // Mock the external calls.
    when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity);
    when(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_RESULTS, Integer.class)).thenReturn(MAX_RESULTS_1);
    when(businessObjectDataDao.getBusinessObjectDataByBusinessObjectFormat(businessObjectFormatEntity, MAX_RESULTS_1)).thenReturn(businessObjectDataKeys);
    // Call the method being tested.
    BusinessObjectDataKeys response = businessObjectDataService.getAllBusinessObjectDataByBusinessObjectFormat(businessObjectFormatKey);
    // Verify the external calls.
    verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, true);
    verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey);
    verify(configurationHelper).getProperty(ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_RESULTS, Integer.class);
    verify(businessObjectDataDao).getBusinessObjectDataByBusinessObjectFormat(businessObjectFormatEntity, MAX_RESULTS_1);
    verifyNoMoreInteractionsHelper();
    // Validate the returned object.
    assertEquals(new BusinessObjectDataKeys(businessObjectDataKeys), response);
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectDataKeys(org.finra.herd.model.api.xml.BusinessObjectDataKeys) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 62 with BusinessObjectFormatKey

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

Example 63 with BusinessObjectFormatKey

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

the class UploadDownloadServiceTestHelper method createUploadSingleInitiationRequest.

/**
 * Creates a upload single initiation request.
 *
 * @param sourceNamespaceCode the source namespace code
 * @param sourceBusinessObjectDefinitionName the source business object definition name
 * @param sourceBusinessObjectFormatUsage the source business object usage
 * @param sourceBusinessObjectFormatFileType the source business object format file type
 * @param sourceBusinessObjectFormatVersion the source business object format version
 * @param targetNamespaceCode the target namespace code
 * @param targetBusinessObjectDefinitionName the target business object definition name
 * @param targetBusinessObjectFormatUsage the target business object usage
 * @param targetBusinessObjectFormatFileType the target business object format file type
 * @param targetBusinessObjectFormatVersion the target business object format version
 * @param fileName the file name
 *
 * @return the newly created upload single initiation request
 */
public UploadSingleInitiationRequest createUploadSingleInitiationRequest(String sourceNamespaceCode, String sourceBusinessObjectDefinitionName, String sourceBusinessObjectFormatUsage, String sourceBusinessObjectFormatFileType, Integer sourceBusinessObjectFormatVersion, String targetNamespaceCode, String targetBusinessObjectDefinitionName, String targetBusinessObjectFormatUsage, String targetBusinessObjectFormatFileType, Integer targetBusinessObjectFormatVersion, String fileName) {
    UploadSingleInitiationRequest request = new UploadSingleInitiationRequest();
    request.setSourceBusinessObjectFormatKey(new BusinessObjectFormatKey(sourceNamespaceCode, sourceBusinessObjectDefinitionName, sourceBusinessObjectFormatUsage, sourceBusinessObjectFormatFileType, sourceBusinessObjectFormatVersion));
    request.setTargetBusinessObjectFormatKey(new BusinessObjectFormatKey(targetNamespaceCode, targetBusinessObjectDefinitionName, targetBusinessObjectFormatUsage, targetBusinessObjectFormatFileType, targetBusinessObjectFormatVersion));
    request.setBusinessObjectDataAttributes(businessObjectDefinitionServiceTestHelper.getNewAttributes());
    request.setFile(new File(fileName, AbstractServiceTest.FILE_SIZE_1_KB));
    return request;
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) File(org.finra.herd.model.api.xml.File)

Example 64 with BusinessObjectFormatKey

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

the class BusinessObjectFormatRestControllerTest method testGetBusinessObjectFormat.

@Test
public void testGetBusinessObjectFormat() {
    BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat(ID, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, true, PARTITION_KEY, FORMAT_DESCRIPTION, NO_ATTRIBUTES, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), null, null, NO_RECORDFLAG, NO_RETENTIONPERIODINDAYS, NO_RETENTIONTYPE);
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION);
    when(businessObjectFormatService.getBusinessObjectFormat(businessObjectFormatKey)).thenReturn(businessObjectFormat);
    // Call GET Business Object Format.
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatRestController.getBusinessObjectFormat(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION);
    // Verify the external calls.
    verify(businessObjectFormatService).getBusinessObjectFormat(businessObjectFormatKey);
    verifyNoMoreInteractions(businessObjectFormatService);
    // Validate the returned object.
    assertEquals(businessObjectFormat, resultBusinessObjectFormat);
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 65 with BusinessObjectFormatKey

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

the class BusinessObjectFormatRestControllerTest method testUpdateBusinessObjectFormatAttributes.

@Test
public void testUpdateBusinessObjectFormatAttributes() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes2();
    BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat();
    businessObjectFormat.setAttributes(attributes);
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION);
    BusinessObjectFormatAttributesUpdateRequest request = new BusinessObjectFormatAttributesUpdateRequest(attributes);
    when(businessObjectFormatService.updateBusinessObjectFormatAttributes(businessObjectFormatKey, request)).thenReturn(businessObjectFormat);
    BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatRestController.updateBusinessObjectFormatAttributes(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, request);
    // Verify the external calls.
    verify(businessObjectFormatService).updateBusinessObjectFormatAttributes(businessObjectFormatKey, request);
    verifyNoMoreInteractions(businessObjectFormatService);
    // Validate the returned object.
    assertEquals(businessObjectFormat, updatedBusinessObjectFormat);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatAttributesUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributesUpdateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Aggregations

BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)166 Test (org.junit.Test)126 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)71 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)62 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)47 Attribute (org.finra.herd.model.api.xml.Attribute)24 ArrayList (java.util.ArrayList)23 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)20 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)17 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)15 BusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest)15 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)15 StorageEntity (org.finra.herd.model.jpa.StorageEntity)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)13 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)10 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)10 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)9 BusinessObjectFormatAttributeDefinitionsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest)9 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)9 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)9