use of org.finra.herd.model.api.xml.BusinessObjectDefinition 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);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition 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);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTestHelper method createBusinessObjectDefinitionFromEntityForSearchTesting.
/**
* Creates a business object definition from a business object definition entity.
*
* @param businessObjectDefinitionEntity the specified business object definition entity
*
* @return the business object definition entity
*/
public BusinessObjectDefinition createBusinessObjectDefinitionFromEntityForSearchTesting(BusinessObjectDefinitionEntity businessObjectDefinitionEntity) {
BusinessObjectDefinition businessObjectDefinition = new BusinessObjectDefinition();
businessObjectDefinition.setNamespace(businessObjectDefinitionEntity.getNamespace().getCode());
businessObjectDefinition.setBusinessObjectDefinitionName(businessObjectDefinitionEntity.getName());
businessObjectDefinition.setDataProviderName(businessObjectDefinitionEntity.getDataProvider().getName());
businessObjectDefinition.setDisplayName(businessObjectDefinitionEntity.getDisplayName());
String toParse = businessObjectDefinitionEntity.getDescription() != null ? businessObjectDefinitionEntity.getDescription() : "";
businessObjectDefinition.setShortDescription(StringUtils.left(Jsoup.parseBodyFragment(toParse).body().text(), configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class)));
return businessObjectDefinition;
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition 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);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method buildGetBusinessObjectDefinitionResponse.
/**
* Builds a business object definition response.
*
* @param response the response
* @param uri the URI of the incoming request
*
* @throws JAXBException if a JAXB error occurred
*/
private void buildGetBusinessObjectDefinitionResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
Pattern pattern = Pattern.compile("/herd-app/rest/businessObjectDefinitions/namespaces/(.*)/businessObjectDefinitionNames/(.*)");
Matcher matcher = pattern.matcher(uri.getPath());
if (matcher.find()) {
BusinessObjectDefinition businessObjectDefinition = new BusinessObjectDefinition();
businessObjectDefinition.setNamespace(matcher.group(1));
businessObjectDefinition.setBusinessObjectDefinitionName(matcher.group(2));
businessObjectDefinition.setDisplayName("testBusinessObjectDefinitionDisplayName");
response.setEntity(getHttpEntity(businessObjectDefinition));
}
}
Aggregations