Search in sources :

Example 66 with BusinessObjectDataEntity

use of org.finra.herd.model.jpa.BusinessObjectDataEntity in project herd by FINRAOS.

the class BusinessObjectDataServiceDeleteBusinessObjectDataTest method testDeleteBusinessObjectDataUpperCaseParameters.

@Test
public void testDeleteBusinessObjectDataUpperCaseParameters() {
    // Create and persist a business object data using lower case values.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION, true, BDATA_STATUS.toLowerCase());
    // Validate that this business object data exists.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION);
    assertNotNull(businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey));
    // Delete the business object data using upper case input parameters (except for case-sensitive partition values).
    BusinessObjectData deletedBusinessObjectData = businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION), false);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION, true, BDATA_STATUS.toLowerCase(), deletedBusinessObjectData);
    // Ensure that this business object format is no longer there.
    assertNull(businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey));
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 67 with BusinessObjectDataEntity

use of org.finra.herd.model.jpa.BusinessObjectDataEntity in project herd by FINRAOS.

the class BusinessObjectDataServiceDeleteBusinessObjectDataTest method testDeleteBusinessObjectDataLatestVersionWhenPreviousVersionExists.

@Test
public void testDeleteBusinessObjectDataLatestVersionWhenPreviousVersionExists() {
    // Create and persist two versions of the business object data.
    BusinessObjectDataEntity initialVersionBusinessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, false, BDATA_STATUS);
    BusinessObjectDataEntity latestVersionBusinessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION, true, BDATA_STATUS);
    // Validate that the initial version does not have the latest version flag set and that second version has it set.
    assertFalse(initialVersionBusinessObjectDataEntity.getLatestVersion());
    assertTrue(latestVersionBusinessObjectDataEntity.getLatestVersion());
    // Delete the latest (second) version of the business object format.
    BusinessObjectData deletedBusinessObjectData = businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION), false);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(latestVersionBusinessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION, true, BDATA_STATUS, deletedBusinessObjectData);
    // Ensure that this business object format is no longer there.
    assertNull(businessObjectDataDao.getBusinessObjectDataByAltKey(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION)));
    // Validate that the initial version now has the latest version flag set.
    initialVersionBusinessObjectDataEntity = businessObjectDataDao.getBusinessObjectDataByAltKey(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
    assertNotNull(initialVersionBusinessObjectDataEntity);
    assertTrue(initialVersionBusinessObjectDataEntity.getLatestVersion());
    // Delete the initial (first) version of the business object format.
    deletedBusinessObjectData = businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION), false);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(initialVersionBusinessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, true, BDATA_STATUS, deletedBusinessObjectData);
    // Ensure that this business object format is no longer there.
    assertNull(businessObjectDataDao.getBusinessObjectDataByAltKey(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION)));
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 68 with BusinessObjectDataEntity

use of org.finra.herd.model.jpa.BusinessObjectDataEntity in project herd by FINRAOS.

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataMissingOptionalParameters.

@Test
public void testGetBusinessObjectDataMissingOptionalParameters() {
    // Create and persist a set of business object data instances without subpartition values.
    List<BusinessObjectDataEntity> businessObjectDataEntities = Arrays.asList(businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION, true, BusinessObjectDataStatusEntity.VALID), businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION, false, BusinessObjectDataStatusEntity.VALID), businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, SECOND_DATA_VERSION, true, BDATA_STATUS));
    // Retrieve business object data entity by not specifying any of the optional parameters including the subpartition values.
    for (String partitionKey : Arrays.asList(null, BLANK_TEXT)) {
        BusinessObjectData resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, PARTITION_VALUE, NO_SUBPARTITION_VALUES, null), partitionKey, NO_BDATA_STATUS, null, null);
        // Validate the returned object.
        businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntities.get(1).getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION, false, BusinessObjectDataStatusEntity.VALID, resultBusinessObjectData);
    }
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 69 with BusinessObjectDataEntity

use of org.finra.herd.model.jpa.BusinessObjectDataEntity in project herd by FINRAOS.

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataInvalidParameters.

@Test
public void testGetBusinessObjectDataInvalidParameters() {
    // Create and persist a valid business object data.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    // Validate that we can perform a get on our business object data.
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS, resultBusinessObjectData);
    // Try to perform a get using invalid business object definition name.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Try to perform a get using invalid format usage.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Try to perform a get using invalid format file type.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Try to perform a get using invalid partition key.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), "I_DO_NOT_EXIST", NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an IllegalArgumentException when using an invalid partition key.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Partition key \"%s\" doesn't match configured business object format partition key \"%s\".", "I_DO_NOT_EXIST", PARTITION_KEY), e.getMessage());
    }
    // Try to perform a get using invalid partition value.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Try to perform a get using invalid subpartition value.
    for (int i = 0; i < SUBPARTITION_VALUES.size(); i++) {
        List<String> testSubPartitionValues = new ArrayList<>();
        try {
            testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
            testSubPartitionValues.set(i, "I_DO_NOT_EXIST");
            businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
            fail("Should throw an ObjectNotFoundException when not able to find business object data.");
        } catch (ObjectNotFoundException e) {
            assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
        }
    }
    // Try to perform a get using too many subpartition values.
    try {
        List<String> testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
        testSubPartitionValues.add("EXTRA_SUBPARTITION_VALUE");
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an IllegalArgumentException when passing too many subpartition values.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Exceeded maximum number of allowed subpartitions: %d.", BusinessObjectDataEntity.MAX_SUBPARTITIONS), e.getMessage());
    }
    // Try to perform a get using invalid business object format version.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Try to perform a get using invalid business object data version.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION, BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Try to perform a get using an invalid business object data status.
    try {
        businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), PARTITION_KEY, BDATA_STATUS_2, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
        fail("Should throw an ObjectNotFoundException when not able to find business object data status.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Business object data status \"%s\" doesn't exist.", BDATA_STATUS_2), e.getMessage());
    }
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ArrayList(java.util.ArrayList) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 70 with BusinessObjectDataEntity

use of org.finra.herd.model.jpa.BusinessObjectDataEntity in project herd by FINRAOS.

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataParentChildPresent.

@Test
public void testGetBusinessObjectDataParentChildPresent() {
    // Create a parent business object data entity.
    BusinessObjectDataEntity businessObjectDataParentEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    // Create an object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    // Create a child business object data entity.
    BusinessObjectDataEntity businessObjectDataChildEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES_2, DATA_VERSION, true, BDATA_STATUS);
    // Associate our business object data entity with the child and parent business object data entities.
    businessObjectDataParentEntity.getBusinessObjectDataChildren().add(businessObjectDataEntity);
    businessObjectDataEntity.getBusinessObjectDataParents().add(businessObjectDataParentEntity);
    businessObjectDataEntity.getBusinessObjectDataChildren().add(businessObjectDataChildEntity);
    businessObjectDataChildEntity.getBusinessObjectDataParents().add(businessObjectDataEntity);
    // Retrieve the business object data.
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS, resultBusinessObjectData);
    // Make sure that the parent data's key is listed.
    assertEquals(1, resultBusinessObjectData.getBusinessObjectDataParents().size());
    assertEquals(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataParentEntity), resultBusinessObjectData.getBusinessObjectDataParents().get(0));
    // Make sure that the child data's key is listed.
    assertEquals(1, resultBusinessObjectData.getBusinessObjectDataChildren().size());
    assertEquals(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataChildEntity), resultBusinessObjectData.getBusinessObjectDataChildren().get(0));
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)278 Test (org.junit.Test)184 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)138 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)105 ArrayList (java.util.ArrayList)70 StorageEntity (org.finra.herd.model.jpa.StorageEntity)67 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)63 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)57 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)54 StorageUnitStatusEntity (org.finra.herd.model.jpa.StorageUnitStatusEntity)31 Attribute (org.finra.herd.model.api.xml.Attribute)28 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)27 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)27 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)27 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)25 Predicate (javax.persistence.criteria.Predicate)24 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)24 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)23 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)21 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)19