Search in sources :

Example 81 with BusinessObjectData

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

the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithSearchWithBdefKey.

@Test
public void testBusinessObjectDataSearchWithSearchWithBdefKey() {
    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_2, 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);
    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());
    }
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) Test(org.junit.Test)

Example 82 with BusinessObjectData

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

the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithSubPartitionValues.

@Test
public void testBusinessObjectDataSearchWithSubPartitionValues() {
    String[] subpartions = { "P1", "P2", "P3", "P4" };
    List<String> subpartitionList = Arrays.asList(subpartions);
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subpartitionList, DATA_VERSION, true, "VALID");
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subpartitionList, DATA_VERSION, true, "INVALID");
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE_2, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subpartitionList, DATA_VERSION, true, "INVALID");
    BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
    businessObjectDataSearchKey.setNamespace(NAMESPACE);
    businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
    List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
    assertEquals(2, result.size());
    result.get(0).getSubPartitionValues().containsAll(subpartitionList);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) Test(org.junit.Test)

Example 83 with BusinessObjectData

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

the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithRetentionExpirationFilter.

@Test
public void testBusinessObjectDataSearchWithRetentionExpirationFilter() {
    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);
    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, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION_2, 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);
    }
    businessObjectDataEntity2.getBusinessObjectFormat().setRetentionType(existingRetentionType);
    businessObjectDataEntity2.getBusinessObjectFormat().setRetentionPeriodInDays(retentionPeriod - 1);
    BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
    businessObjectDataSearchKey.setNamespace(NAMESPACE);
    businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
    businessObjectDataSearchKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    businessObjectDataSearchKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
    businessObjectDataSearchKey.setFilterOnRetentionExpiration(true);
    List<BusinessObjectData> result = businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
    assertEquals(2, result.size());
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) RetentionTypeEntity(org.finra.herd.model.jpa.RetentionTypeEntity) Test(org.junit.Test)

Example 84 with BusinessObjectData

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

the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithPartitionValueRangeFiltersSubPartition.

@Test
public void testBusinessObjectDataSearchWithPartitionValueRangeFiltersSubPartition() {
    BusinessObjectDataEntity businessObjectDataEntity = createBusinessObjectEntityForPartitionValueFilterTest();
    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<PartitionValueFilter> partitionValueFilters = new ArrayList<>();
    PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
    partitionValueFilters.add(partitionValueFilter);
    partitionValueFilter.setPartitionKey(PARTITION_KEY + "1");
    PartitionValueRange partitionValueRange = new PartitionValueRange();
    partitionValueRange.setStartPartitionValue(businessObjectDataEntity.getPartitionValue2());
    partitionValueRange.setEndPartitionValue(businessObjectDataEntity.getPartitionValue2() + "1");
    partitionValueFilter.setPartitionValueRange(partitionValueRange);
    businessObjectDataSearchKey.setPartitionValueFilters(partitionValueFilters);
    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(bDefName, data.getBusinessObjectDefinitionName());
        assertEquals(usage, data.getBusinessObjectFormatUsage());
        assertEquals(fileTypeCode, data.getBusinessObjectFormatFileType());
        assertTrue(formatVersion == data.getBusinessObjectFormatVersion());
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 85 with BusinessObjectData

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

the class BusinessObjectDataDaoTest method testBusinessObjectDataSearchWithPartitionValueRangeFilters.

@Test
public void testBusinessObjectDataSearchWithPartitionValueRangeFilters() {
    BusinessObjectDataEntity businessObjectDataEntity = createBusinessObjectEntityForPartitionValueFilterTest();
    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<PartitionValueFilter> partitionValueFilters = new ArrayList<>();
    PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
    partitionValueFilters.add(partitionValueFilter);
    partitionValueFilter.setPartitionKey(PARTITION_KEY);
    PartitionValueRange partitionValueRange = new PartitionValueRange();
    partitionValueRange.setStartPartitionValue(PARTITION_VALUE);
    partitionValueRange.setEndPartitionValue(PARTITION_VALUE + "1");
    partitionValueFilter.setPartitionValueRange(partitionValueRange);
    businessObjectDataSearchKey.setPartitionValueFilters(partitionValueFilters);
    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(bDefName, data.getBusinessObjectDefinitionName());
        assertEquals(usage, data.getBusinessObjectFormatUsage());
        assertEquals(fileTypeCode, data.getBusinessObjectFormatFileType());
        assertTrue(formatVersion == data.getBusinessObjectFormatVersion());
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Aggregations

BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)150 Test (org.junit.Test)121 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)64 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)57 ArrayList (java.util.ArrayList)39 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)29 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)25 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)19 Storage (org.finra.herd.model.api.xml.Storage)19 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 Attribute (org.finra.herd.model.api.xml.Attribute)15 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)14 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)12 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)11 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)9 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)8 UploaderInputManifestDto (org.finra.herd.model.dto.UploaderInputManifestDto)8 IOException (java.io.IOException)7 BusinessObjectDataRetryStoragePolicyTransitionRequest (org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest)7 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)7