use of org.finra.herd.model.api.xml.SampleDataFile in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testGetBusinessObjectDefinitionValidateSampleDataFilesOrder.
@Test
public void testGetBusinessObjectDefinitionValidateSampleDataFilesOrder() throws Exception {
// Create and persist a business object definition entity with sample data files created out of order.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), Arrays.asList(new SampleDataFile(DIRECTORY_PATH_2, FILE_NAME_2), new SampleDataFile(DIRECTORY_PATH, FILE_NAME_2), new SampleDataFile(DIRECTORY_PATH, FILE_NAME)));
// Retrieve the business object definition.
BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, Arrays.asList(new SampleDataFile(DIRECTORY_PATH, FILE_NAME), new SampleDataFile(DIRECTORY_PATH, FILE_NAME_2), new SampleDataFile(DIRECTORY_PATH_2, FILE_NAME_2)), businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.SampleDataFile in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionSampleFilesAddFile.
@Test
public void testUpdateBusinessObjectDefinitionSampleFilesAddFile() {
// 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 and persist a business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectDefinitionServiceTestHelper.getTestSampleDataFiles());
String fileName = "testfile.csv";
long fileSize = 1820L;
String path = NAMESPACE + "/" + BDEF_NAME + "/";
BusinessObjectDefinitionSampleFileUpdateDto sampleFileUpdateDto = new BusinessObjectDefinitionSampleFileUpdateDto(path, fileName, fileSize);
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
businessObjectDefinitionServiceImpl.updateBusinessObjectDefinitionEntitySampleFile(businessObjectDefinitionKey, sampleFileUpdateDto);
BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
List<SampleDataFile> updatedSampleDataFileList = businessObjectDefinitionServiceTestHelper.getTestSampleDataFiles();
updatedSampleDataFileList.add(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, updatedSampleDataFileList, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.SampleDataFile in project herd by FINRAOS.
the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionSampleFileUpperCaseParameters.
@Test
public void testDownloadBusinessObjectDefinitionSampleFileUpperCaseParameters() {
// Create and persist a business object definition entity.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectDefinitionServiceTestHelper.getTestSampleDataFiles());
List<SampleDataFile> sampleFileList = businessObjectDefinitionServiceTestHelper.getTestSampleDataFiles();
StorageEntity storageEntity = storageDaoHelper.getStorageEntity(STORAGE_NAME);
storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucketName"));
storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_DOWNLOAD_ROLE_ARN), "downloadRole"));
DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest downloadRequest = new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest();
BusinessObjectDefinitionSampleDataFileKey sampleDataFileKey = new BusinessObjectDefinitionSampleDataFileKey();
sampleDataFileKey.setBusinessObjectDefinitionName(BDEF_NAME);
sampleDataFileKey.setNamespace(NAMESPACE);
sampleDataFileKey.setDirectoryPath(sampleFileList.get(0).getDirectoryPath());
sampleDataFileKey.setFileName(sampleFileList.get(0).getFileName());
// use the lower case name space and business definition still return the same response
BusinessObjectDefinitionSampleDataFileKey sampleDataFileKeyUpperCase = new BusinessObjectDefinitionSampleDataFileKey();
sampleDataFileKeyUpperCase.setBusinessObjectDefinitionName(BDEF_NAME.toUpperCase());
sampleDataFileKeyUpperCase.setNamespace(NAMESPACE.toUpperCase());
sampleDataFileKeyUpperCase.setDirectoryPath(sampleFileList.get(0).getDirectoryPath());
sampleDataFileKeyUpperCase.setFileName(sampleFileList.get(0).getFileName());
downloadRequest.setBusinessObjectDefinitionSampleDataFileKey(sampleDataFileKeyUpperCase);
DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse downloadResponse = uploadDownloadService.initiateDownloadSingleSampleFile(downloadRequest);
assertEquals(downloadResponse.getBusinessObjectDefinitionSampleDataFileKey(), sampleDataFileKey);
assertNotNull(downloadResponse.getAwsS3BucketName());
assertNotNull(downloadResponse.getAwsAccessKey());
assertNotNull(downloadResponse.getAwsSecretKey());
assertNotNull(downloadResponse.getAwsSessionExpirationTime());
assertNotNull(downloadResponse.getAwsSessionToken());
assertNotNull(downloadResponse.getPreSignedUrl());
}
use of org.finra.herd.model.api.xml.SampleDataFile in project herd by FINRAOS.
the class BusinessObjectDefinitionRestControllerTest method testDeleteBusinessObjectDefinition.
@Test
public void testDeleteBusinessObjectDefinition() {
// 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.deleteBusinessObjectDefinition(businessObjectDefinitionKey)).thenReturn(businessObjectDefinition);
// Call the method under test.
BusinessObjectDefinition result = businessObjectDefinitionRestController.deleteBusinessObjectDefinition(BDEF_NAMESPACE, BDEF_NAME);
// Verify the external calls.
verify(businessObjectDefinitionService).deleteBusinessObjectDefinition(businessObjectDefinitionKey);
verifyNoMoreInteractions(businessObjectDefinitionService);
// Validate the returned object.
assertEquals(businessObjectDefinition, result);
}
use of org.finra.herd.model.api.xml.SampleDataFile in project herd by FINRAOS.
the class BusinessObjectDefinitionRestControllerTest method testUpdateBusinessObjectDefinition.
@Test
public void testUpdateBusinessObjectDefinition() {
// Create a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create a business object definition update request.
BusinessObjectDefinitionUpdateRequest businessObjectDefinitionUpdateRequest = new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2)));
// 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.updateBusinessObjectDefinition(businessObjectDefinitionKey, businessObjectDefinitionUpdateRequest)).thenReturn(businessObjectDefinition);
// Call the method under test.
BusinessObjectDefinition result = businessObjectDefinitionRestController.updateBusinessObjectDefinition(BDEF_NAMESPACE, BDEF_NAME, businessObjectDefinitionUpdateRequest);
// Verify the external calls.
verify(businessObjectDefinitionService).updateBusinessObjectDefinition(businessObjectDefinitionKey, businessObjectDefinitionUpdateRequest);
verifyNoMoreInteractions(businessObjectDefinitionService);
// Validate the results.
assertEquals(businessObjectDefinition, result);
}
Aggregations