use of org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest in project herd by FINRAOS.
the class UploadDownloadRestControllerTest method testInitiateUploadSampleFile.
@Test
public void testInitiateUploadSampleFile() {
// Create a business object data key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create a request.
UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(businessObjectDefinitionKey);
// Create a response.
UploadBusinessObjectDefinitionSampleDataFileInitiationResponse response = new UploadBusinessObjectDefinitionSampleDataFileInitiationResponse(businessObjectDefinitionKey, S3_BUCKET_NAME, S3_ENDPOINT, S3_KEY_PREFIX, AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME);
// Mock the external calls.
when(uploadDownloadService.initiateUploadSampleFile(request)).thenReturn(response);
// Call the method under test.
UploadBusinessObjectDefinitionSampleDataFileInitiationResponse result = uploadDownloadRestController.initiateUploadSampleFile(request);
// Verify the external calls.
verify(uploadDownloadService).initiateUploadSampleFile(request);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(response, result);
}
use of org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFileUpperCase.
@Test
public void testUploadBusinessObjectDefinitionSampleFileUpperCase() {
String s3_velocity_template = "$namespace/$businessObjectDefinitionName";
// Create a test storage.
storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), UPLOADER_ROLE_ARN), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), s3_velocity_template)));
// Create and persist a business object definition entity with sample data files.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest();
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
BusinessObjectDefinitionKey businessObjectDefinitionKeyUpperCase = new BusinessObjectDefinitionKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase());
request.setBusinessObjectDefinitionKey(businessObjectDefinitionKeyUpperCase);
UploadBusinessObjectDefinitionSampleDataFileInitiationResponse response = uploadDownloadService.initiateUploadSampleFile(request);
assertEquals(response.getBusinessObjectDefinitionKey(), businessObjectDefinitionKey);
assertEquals(response.getAwsS3BucketName(), S3_BUCKET_NAME);
assertEquals(response.getAwsAccessKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_ACCESS_KEY);
assertEquals(response.getAwsSecretKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SECRET_KEY);
assertEquals(response.getAwsSessionToken(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SESSION_TOKEN);
}
use of org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFileTrimedParameters.
@Test
public void testUploadBusinessObjectDefinitionSampleFileTrimedParameters() {
String s3_velocity_template = "$namespace/$businessObjectDefinitionName";
// Create a test storage.
storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), UPLOADER_ROLE_ARN), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), s3_velocity_template)));
// Create and persist a business object definition entity with sample data files.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest();
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
BusinessObjectDefinitionKey businessObjectDefinitionKeyWhitespace = new BusinessObjectDefinitionKey(" " + NAMESPACE + " ", " " + BDEF_NAME + " ");
request.setBusinessObjectDefinitionKey(businessObjectDefinitionKeyWhitespace);
UploadBusinessObjectDefinitionSampleDataFileInitiationResponse response = uploadDownloadService.initiateUploadSampleFile(request);
assertEquals(response.getBusinessObjectDefinitionKey(), businessObjectDefinitionKey);
assertEquals(response.getAwsS3BucketName(), S3_BUCKET_NAME);
assertEquals(response.getAwsAccessKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_ACCESS_KEY);
assertEquals(response.getAwsSecretKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SECRET_KEY);
assertEquals(response.getAwsSessionToken(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SESSION_TOKEN);
}
Aggregations