Search in sources :

Example 6 with SampleDataFile

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

the class BusinessObjectDefinitionRestControllerTest method testSearchBusinessObjectDefinition.

@Test
public void testSearchBusinessObjectDefinition() {
    // Create a business object definition search request.
    BusinessObjectDefinitionSearchRequest request = new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY)))));
    // 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);
    // Create a business object definition search response.
    BusinessObjectDefinitionSearchResponse businessObjectDefinitionSearchResponse = new BusinessObjectDefinitionSearchResponse(Arrays.asList(businessObjectDefinition));
    // Create a set of search optional fields.
    Set<String> fields = Sets.newHashSet(FIELD_DATA_PROVIDER_NAME, FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
    // Mock the external calls.
    when(businessObjectDefinitionService.searchBusinessObjectDefinitions(request, fields)).thenReturn(businessObjectDefinitionSearchResponse);
    // Call the method under test.
    BusinessObjectDefinitionSearchResponse result = businessObjectDefinitionSearchResponse = businessObjectDefinitionRestController.searchBusinessObjectDefinitions(fields, request);
    // Verify the external calls.
    verify(businessObjectDefinitionService).searchBusinessObjectDefinitions(request, fields);
    verifyNoMoreInteractions(businessObjectDefinitionService);
    // Validate the results.
    assertEquals(businessObjectDefinitionSearchResponse, result);
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) Attribute(org.finra.herd.model.api.xml.Attribute) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) Test(org.junit.Test)

Example 7 with SampleDataFile

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

the class BusinessObjectDefinitionRestControllerTest method testUpdateBusinessObjectDefinitionDescriptiveInformation.

@Test
public void testUpdateBusinessObjectDefinitionDescriptiveInformation() {
    // Create a business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
    // Create a business object definition descriptive information update request.
    BusinessObjectDefinitionDescriptiveInformationUpdateRequest request = new BusinessObjectDefinitionDescriptiveInformationUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, new DescriptiveBusinessObjectFormatUpdateRequest(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE));
    // 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.updateBusinessObjectDefinitionDescriptiveInformation(businessObjectDefinitionKey, request)).thenReturn(businessObjectDefinition);
    // Call the method under test.
    BusinessObjectDefinition result = businessObjectDefinitionRestController.updateBusinessObjectDefinitionDescriptiveInformation(BDEF_NAMESPACE, BDEF_NAME, request);
    // Verify the external calls.
    verify(businessObjectDefinitionService).updateBusinessObjectDefinitionDescriptiveInformation(businessObjectDefinitionKey, request);
    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) BusinessObjectDefinitionDescriptiveInformationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Example 8 with SampleDataFile

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

the class BusinessObjectDefinitionDaoTestHelper method createBusinessObjectDefinitionEntity.

/**
 * Creates and persists a new business object definition entity.
 *
 * @return the newly created business object definition entity
 */
public BusinessObjectDefinitionEntity createBusinessObjectDefinitionEntity(NamespaceEntity namespaceEntity, String businessObjectDefinitionName, DataProviderEntity dataProviderEntity, String businessObjectDefinitionDescription, String displayName, List<Attribute> attributes, List<SampleDataFile> sampleDataFiles) {
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity();
    businessObjectDefinitionEntity.setNamespace(namespaceEntity);
    businessObjectDefinitionEntity.setDataProvider(dataProviderEntity);
    businessObjectDefinitionEntity.setName(businessObjectDefinitionName);
    businessObjectDefinitionEntity.setDescription(businessObjectDefinitionDescription);
    businessObjectDefinitionEntity.setDisplayName(displayName);
    // Create business object definition attribute entities if they are specified.
    if (!CollectionUtils.isEmpty(attributes)) {
        List<BusinessObjectDefinitionAttributeEntity> attributeEntities = new ArrayList<>();
        businessObjectDefinitionEntity.setAttributes(attributeEntities);
        for (Attribute attribute : attributes) {
            BusinessObjectDefinitionAttributeEntity attributeEntity = new BusinessObjectDefinitionAttributeEntity();
            attributeEntities.add(attributeEntity);
            attributeEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
            attributeEntity.setName(attribute.getName());
            attributeEntity.setValue(attribute.getValue());
        }
    }
    // Create business object definition sample data file entities if they are specified.
    if (!CollectionUtils.isEmpty(sampleDataFiles)) {
        // Create a storage entity if needed.
        StorageEntity storageEntity = storageDao.getStorageByName(AbstractDaoTest.STORAGE_NAME);
        if (storageEntity == null) {
            storageEntity = storageDaoTestHelper.createStorageEntity(AbstractDaoTest.STORAGE_NAME);
        }
        // Create sample data file entities.
        List<BusinessObjectDefinitionSampleDataFileEntity> sampleDataFileEntities = new ArrayList<>();
        businessObjectDefinitionEntity.setSampleDataFiles(sampleDataFileEntities);
        for (SampleDataFile sampleDataFile : sampleDataFiles) {
            BusinessObjectDefinitionSampleDataFileEntity sampleDataFileEntity = new BusinessObjectDefinitionSampleDataFileEntity();
            sampleDataFileEntities.add(sampleDataFileEntity);
            sampleDataFileEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
            sampleDataFileEntity.setDirectoryPath(sampleDataFile.getDirectoryPath());
            sampleDataFileEntity.setFileName(sampleDataFile.getFileName());
            sampleDataFileEntity.setFileSizeBytes(AbstractDaoTest.FILE_SIZE_1_KB);
            sampleDataFileEntity.setStorage(storageEntity);
        }
    }
    return businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionEntity);
}
Also used : BusinessObjectDefinitionAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionAttributeEntity) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDefinitionSampleDataFileEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSampleDataFileEntity)

Example 9 with SampleDataFile

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

the class SampleDataJmsMessageListenerTest method testS3Message.

@Test
public void testS3Message() throws Exception {
    // Create and persist database entities required for testing.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
    storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME)));
    // Create a business object definition.
    BusinessObjectDefinitionCreateRequest request = new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
    businessObjectDefinitionService.createBusinessObjectDefinition(request);
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    String fileName = "test1.csv";
    String filePath = NAMESPACE + "/" + BDEF_NAME + "/" + fileName;
    long fileSize = 1024L;
    S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, fileSize, null, null), null);
    List<S3EventNotificationRecord> records = new ArrayList<>();
    records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null));
    S3EventNotification s3EventNotification = new S3EventNotification(records);
    sampleDataJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null);
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, false);
    List<SampleDataFile> sampleDataFiles = Arrays.asList(new SampleDataFile(NAMESPACE + "/" + BDEF_NAME + "/", fileName));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(updatedBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, sampleDataFiles, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
Also used : S3Entity(com.amazonaws.services.s3.event.S3EventNotification.S3Entity) BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) ArrayList(java.util.ArrayList) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) S3EventNotification(com.amazonaws.services.s3.event.S3EventNotification) S3ObjectEntity(com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) S3EventNotificationRecord(com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 10 with SampleDataFile

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

SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)21 Test (org.junit.Test)18 Attribute (org.finra.herd.model.api.xml.Attribute)16 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)14 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)11 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)8 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)7 ArrayList (java.util.ArrayList)6 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)5 BusinessObjectDefinitionSampleDataFileKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey)5 DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest (org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest)5 DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse (org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse)4 StorageEntity (org.finra.herd.model.jpa.StorageEntity)4 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)3 BusinessObjectDefinitionSampleFileUpdateDto (org.finra.herd.model.dto.BusinessObjectDefinitionSampleFileUpdateDto)3 S3EventNotification (com.amazonaws.services.s3.event.S3EventNotification)2 S3Entity (com.amazonaws.services.s3.event.S3EventNotification.S3Entity)2 S3EventNotificationRecord (com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord)2 S3ObjectEntity (com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity)2 BusinessObjectDefinitionChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent)2