Search in sources :

Example 11 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionLowerCaseParameters.

@Test
public void testCreateBusinessObjectDefinitionLowerCaseParameters() {
    // Create and persist database entities required for testing using upper case values.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting(NAMESPACE.toUpperCase(), DATA_PROVIDER_NAME.toUpperCase());
    // Create a business object definition using upper case input parameters.
    BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), DATA_PROVIDER_NAME.toLowerCase(), BDEF_DESCRIPTION.toLowerCase(), BDEF_DISPLAY_NAME.toLowerCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toLowerCase()))));
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE.toUpperCase(), BDEF_NAME.toLowerCase(), DATA_PROVIDER_NAME.toUpperCase(), BDEF_DESCRIPTION.toLowerCase(), NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME.toLowerCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toLowerCase())), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 12 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionSampleFilesMissingFileName.

@Test
public void testUpdateBusinessObjectDefinitionSampleFilesMissingFileName() {
    // 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);
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    String fileName = "";
    long fileSize = 1820L;
    String path = NAMESPACE + "/" + BDEF_NAME + "/";
    BusinessObjectDefinitionSampleFileUpdateDto sampleFileUpdateDto = new BusinessObjectDefinitionSampleFileUpdateDto(path, fileName, fileSize);
    try {
        businessObjectDefinitionServiceImpl.updateBusinessObjectDefinitionEntitySampleFile(businessObjectDefinitionKey, sampleFileUpdateDto);
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "A file name must be specified.");
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionSampleFileUpdateDto(org.finra.herd.model.dto.BusinessObjectDefinitionSampleFileUpdateDto) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 13 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testGetBusinessObjectDefinitionNewTransaction.

/**
 * This method is to get coverage for the business object definition service method that starts a new transaction.
 */
@Test
public void testGetBusinessObjectDefinitionNewTransaction() throws Exception {
    try {
        businessObjectDefinitionServiceImpl.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest());
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    try {
        businessObjectDefinitionServiceImpl.deleteBusinessObjectDefinition(new BusinessObjectDefinitionKey());
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    try {
        businessObjectDefinitionServiceImpl.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(), NOT_INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    try {
        businessObjectDefinitionServiceImpl.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(), new BusinessObjectDefinitionUpdateRequest());
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    try {
        businessObjectDefinitionServiceImpl.updateBusinessObjectDefinitionDescriptiveInformation(new BusinessObjectDefinitionKey(), new BusinessObjectDefinitionDescriptiveInformationUpdateRequest());
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    businessObjectDefinitionServiceImpl.updateSearchIndexDocumentBusinessObjectDefinition(new SearchIndexUpdateDto(SearchIndexUpdateDto.MESSAGE_TYPE_BUSINESS_OBJECT_DEFINITION_UPDATE, new ArrayList<>(), SearchIndexUpdateDto.SEARCH_INDEX_UPDATE_TYPE_CREATE));
}
Also used : BusinessObjectDefinitionDescriptiveInformationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) ArrayList(java.util.ArrayList) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) BusinessObjectDefinitionUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Test(org.junit.Test)

Example 14 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionSampleFiles.

@Test
public void testUpdateBusinessObjectDefinitionSampleFiles() {
    // 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 = "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> 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 : 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) BusinessObjectDefinitionSampleFileUpdateDto(org.finra.herd.model.dto.BusinessObjectDefinitionSampleFileUpdateDto) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 15 with BusinessObjectDefinitionCreateRequest

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

the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinition.

@Test
public void testCreateBusinessObjectDefinition() throws Exception {
    // Create and persist database entities required for testing.
    businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
    // Create a business object definition.
    BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes()));
    // Get the business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    assertNotNull(businessObjectDefinitionEntity);
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
    // Retrieve the business object definition with include update history flag set to true.
    resultBusinessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), INCLUDE_BUSINESS_OBJECT_DEFINITION_UPDATE_HISTORY);
    // Create business object definition change event.
    List<BusinessObjectDefinitionChangeEvent> businessObjectDefinitionChangeEvents = new ArrayList<>();
    businessObjectDefinitionChangeEvents.add(new BusinessObjectDefinitionChangeEvent(BDEF_DISPLAY_NAME, BDEF_DESCRIPTION, NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT_UPDATE_REQUEST, resultBusinessObjectDefinition.getBusinessObjectDefinitionChangeEvents().get(0).getEventTime(), resultBusinessObjectDefinition.getBusinessObjectDefinitionChangeEvents().get(0).getUserId()));
    // Validate the result.
    assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), businessObjectDefinitionChangeEvents), resultBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionChangeEvent(org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent) ArrayList(java.util.ArrayList) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)23 Test (org.junit.Test)22 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)16 Attribute (org.finra.herd.model.api.xml.Attribute)15 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)14 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)14 ArrayList (java.util.ArrayList)5 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)5 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)4 S3EventNotification (com.amazonaws.services.s3.event.S3EventNotification)3 S3Entity (com.amazonaws.services.s3.event.S3EventNotification.S3Entity)3 S3EventNotificationRecord (com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord)3 S3ObjectEntity (com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity)3 BusinessObjectDefinitionSampleFileUpdateDto (org.finra.herd.model.dto.BusinessObjectDefinitionSampleFileUpdateDto)3 HashMap (java.util.HashMap)1 AbstractAppTest (org.finra.herd.app.AbstractAppTest)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinitionChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent)1 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)1