use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithLatestValidVersionNoExisting.
@Test
public void testBusinessObjectDataSearchWithLatestValidVersionNoExisting() {
// to validate that the latest flag is not used by this method to find the latest (maximum) business object data version.
for (Integer version : Arrays.asList(INITIAL_DATA_VERSION, SECOND_DATA_VERSION, THIRD_DATA_VERSION)) {
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, version, version.equals(SECOND_DATA_VERSION), BDATA_STATUS);
}
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
businessObjectDataSearchKey.setNamespace(NAMESPACE);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataSearchKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
businessObjectDataSearchKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
businessObjectDataSearchKey.setBusinessObjectFormatVersion(FORMAT_VERSION);
businessObjectDataSearchKey.setFilterOnLatestValidVersion(true);
List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
assertEquals(0, result.size());
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithAllSearchKeyFields.
@Test
public void testBusinessObjectDataSearchWithAllSearchKeyFields() {
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, true, "VALID");
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, true, "INVALID");
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE_2, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, true, "INVALID");
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
businessObjectDataSearchKey.setNamespace(NAMESPACE);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataSearchKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
businessObjectDataSearchKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
businessObjectDataSearchKey.setBusinessObjectFormatVersion(FORMAT_VERSION);
List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
assertEquals(2, result.size());
for (BusinessObjectData data : result) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(FORMAT_USAGE_CODE, data.getBusinessObjectFormatUsage());
assertEquals(FORMAT_FILE_TYPE_CODE, data.getBusinessObjectFormatFileType());
assertTrue(FORMAT_VERSION == data.getBusinessObjectFormatVersion());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithLatestValidVersion.
@Test
public void testBusinessObjectDataSearchWithLatestValidVersion() {
// Create multiple version of the same business object data with the latest
// version not having the latest flag set. The latest flag is incorrectly set for the second version. This is done
// to validate that the latest flag is not used by this method to find the latest (maximum) business object data version
BusinessObjectData expectedBData1 = null;
String BData_Status = "VALID";
for (Integer version : Arrays.asList(INITIAL_DATA_VERSION, SECOND_DATA_VERSION, THIRD_DATA_VERSION)) {
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, version, version.equals(SECOND_DATA_VERSION), BData_Status);
if (version.equals(THIRD_DATA_VERSION)) {
expectedBData1 = new BusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, AbstractDaoTest.PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, version, businessObjectDataEntity.getLatestVersion(), BData_Status, null, null, null, null, null);
}
}
BusinessObjectData expectedBData2 = null;
for (Integer version : Arrays.asList(INITIAL_DATA_VERSION, SECOND_DATA_VERSION, THIRD_DATA_VERSION)) {
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION_2, PARTITION_VALUE, SUBPARTITION_VALUES, version, version.equals(SECOND_DATA_VERSION), BData_Status);
if (version.equals(THIRD_DATA_VERSION)) {
expectedBData2 = new BusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION_2, AbstractDaoTest.PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, version, businessObjectDataEntity.getLatestVersion(), BData_Status, null, null, null, null, null);
}
}
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
businessObjectDataSearchKey.setNamespace(NAMESPACE);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataSearchKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
businessObjectDataSearchKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
businessObjectDataSearchKey.setFilterOnLatestValidVersion(true);
List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
assertEquals(2, result.size());
assertTrue(result.contains(expectedBData1));
assertTrue(result.contains(expectedBData2));
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithRetentionExpirationFilterMultipleFormats.
@Test
public void testBusinessObjectDataSearchWithRetentionExpirationFilterMultipleFormats() {
int retentionPeriod = 180;
java.util.Date date = DateUtils.addDays(new java.util.Date(), -1 * retentionPeriod);
String partitionValueDate = DateFormatUtils.format(date, AbstractHerdDao.DEFAULT_SINGLE_DAY_DATE_MASK);
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, partitionValueDate, null, DATA_VERSION, true, "VALID");
BusinessObjectDataEntity businessObjectDataEntity2 = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, partitionValueDate, null, DATA_VERSION, true, "INVALID");
BusinessObjectDataEntity businessObjectDataEntity3 = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_3, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, partitionValueDate, null, DATA_VERSION, true, "INVALID");
BusinessObjectDataEntity businessObjectDataEntity4 = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_3, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION, partitionValueDate, null, DATA_VERSION, true, "INVALID");
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE_2, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, partitionValueDate, null, DATA_VERSION, true, "INVALID");
RetentionTypeEntity existingRetentionType = retentionTypeDao.getRetentionTypeByCode(RetentionTypeEntity.PARTITION_VALUE);
if (existingRetentionType == null) {
retentionTypeDaoTestHelper.createRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE);
}
businessObjectDataEntity.getBusinessObjectFormat().setRetentionType(existingRetentionType);
businessObjectDataEntity.getBusinessObjectFormat().setRetentionPeriodInDays(retentionPeriod - 1);
businessObjectDataEntity2.getBusinessObjectFormat().setRetentionType(existingRetentionType);
businessObjectDataEntity2.getBusinessObjectFormat().setRetentionPeriodInDays(retentionPeriod - 1);
businessObjectDataEntity3.getBusinessObjectFormat().setRetentionType(existingRetentionType);
businessObjectDataEntity3.getBusinessObjectFormat().setRetentionPeriodInDays(null);
RetentionTypeEntity notFoundRetentionTypeEntity = retentionTypeDaoTestHelper.createRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE + "NOTFOUND");
businessObjectDataEntity4.getBusinessObjectFormat().setRetentionType(notFoundRetentionTypeEntity);
businessObjectDataEntity4.getBusinessObjectFormat().setRetentionPeriodInDays(retentionPeriod);
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
businessObjectDataSearchKey.setNamespace(NAMESPACE);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataSearchKey.setFilterOnRetentionExpiration(true);
List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
assertEquals(2, result.size());
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithAttributeValueFiltersResponseCheckMatch.
@Test
public void testBusinessObjectDataSearchWithAttributeValueFiltersResponseCheckMatch() {
// Create and persist an attribute for the business object data
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_1);
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataAttributeEntity.getBusinessObjectData();
String namespace = businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getNamespace().getCode();
String bDefName = businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getName();
String usage = businessObjectDataEntity.getBusinessObjectFormat().getUsage();
String fileTypeCode = businessObjectDataEntity.getBusinessObjectFormat().getFileType().getCode();
int formatVersion = businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectFormatVersion();
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
List<AttributeValueFilter> attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1));
attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_1));
businessObjectDataSearchKey.setAttributeValueFilters(attributeValueFilters);
businessObjectDataSearchKey.setNamespace(namespace);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(bDefName);
businessObjectDataSearchKey.setBusinessObjectFormatUsage(usage);
businessObjectDataSearchKey.setBusinessObjectFormatFileType(fileTypeCode);
businessObjectDataSearchKey.setBusinessObjectFormatVersion(formatVersion);
List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
assertEquals(1, result.size());
for (BusinessObjectData data : result) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(FORMAT_USAGE_CODE, data.getBusinessObjectFormatUsage());
assertEquals(FORMAT_FILE_TYPE_CODE, data.getBusinessObjectFormatFileType());
assertTrue(FORMAT_VERSION == data.getBusinessObjectFormatVersion());
assertEquals(data.getAttributes().size(), 2);
assertEquals(ATTRIBUTE_NAME_1_MIXED_CASE, data.getAttributes().get(0).getName());
assertEquals(ATTRIBUTE_NAME_2_MIXED_CASE, data.getAttributes().get(1).getName());
assertEquals(ATTRIBUTE_VALUE_1, data.getAttributes().get(0).getValue());
}
}
Aggregations