Search in sources :

Example 16 with PartitionValueRange

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

the class ExpectedPartitionValueDaoTest method testGetExpectedPartitionValuesByGroupAndNoRange.

/**
 * Test DAO method to retrieve expected partition values with no range (specified 2 ways). In the month of April, 2014, the number of values (i.e.
 * non-weekend days) is 22.
 */
@Test
public void testGetExpectedPartitionValuesByGroupAndNoRange() {
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueProcessDatesForApril2014(PARTITION_KEY_GROUP);
    // Null range.
    List<ExpectedPartitionValueEntity> expectedPartitionValueEntities = expectedPartitionValueDao.getExpectedPartitionValuesByGroupAndRange(PARTITION_KEY_GROUP, null);
    assertEquals(expectedPartitionValueEntities.size(), 22, expectedPartitionValueEntities.size());
    // Range with no start or end.
    PartitionValueRange partitionValueRange = new PartitionValueRange();
    expectedPartitionValueEntities = expectedPartitionValueDao.getExpectedPartitionValuesByGroupAndRange(PARTITION_KEY_GROUP, partitionValueRange);
    assertEquals(expectedPartitionValueEntities.size(), 22, expectedPartitionValueEntities.size());
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValueEntity(org.finra.herd.model.jpa.ExpectedPartitionValueEntity) Test(org.junit.Test)

Example 17 with PartitionValueRange

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

the class ExpectedPartitionValueRestControllerTest method testGetExpectedPartitionValues.

@Test
public void testGetExpectedPartitionValues() {
    PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey();
    partitionKeyGroupKey.setPartitionKeyGroupName(PARTITION_KEY_GROUP);
    List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
    int startExpectedPartitionValueIndex = 1;
    int endExpectedPartitionValueIndex = testSortedExpectedPartitionValues.size() - 2;
    PartitionValueRange partitionValueRange = new PartitionValueRange();
    partitionValueRange.setStartPartitionValue(testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex));
    partitionValueRange.setEndPartitionValue(testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex));
    ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues().subList(startExpectedPartitionValueIndex, endExpectedPartitionValueIndex));
    when(expectedPartitionValueService.getExpectedPartitionValues(partitionKeyGroupKey, partitionValueRange)).thenReturn(expectedPartitionValuesInformation);
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueRestController.getExpectedPartitionValues(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex), testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(startExpectedPartitionValueIndex, endExpectedPartitionValueIndex), resultPartitionValuesInformation);
    // Verify the external calls.
    verify(expectedPartitionValueService).getExpectedPartitionValues(partitionKeyGroupKey, partitionValueRange);
    verifyNoMoreInteractions(expectedPartitionValueService);
    // Validate the returned object.
    assertEquals(expectedPartitionValuesInformation, resultPartitionValuesInformation);
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 18 with PartitionValueRange

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

the class BusinessObjectDataServiceTestHelper method getTestBusinessObjectDataAvailabilityRequest.

/**
 * Creates and returns a business object data availability request using passed parameters along with some hard-coded test values.
 *
 * @param partitionKey the partition key
 * @param startPartitionValue the start partition value for the partition value range
 * @param endPartitionValue the end partition value for the partition value range
 * @param partitionValues the list of partition values
 *
 * @return the newly created business object data availability request
 */
public BusinessObjectDataAvailabilityRequest getTestBusinessObjectDataAvailabilityRequest(String partitionKey, String startPartitionValue, String endPartitionValue, List<String> partitionValues) {
    BusinessObjectDataAvailabilityRequest request = new BusinessObjectDataAvailabilityRequest();
    request.setNamespace(AbstractServiceTest.NAMESPACE);
    request.setBusinessObjectDefinitionName(AbstractServiceTest.BDEF_NAME);
    request.setBusinessObjectFormatUsage(AbstractServiceTest.FORMAT_USAGE_CODE);
    request.setBusinessObjectFormatFileType(AbstractServiceTest.FORMAT_FILE_TYPE_CODE);
    request.setBusinessObjectFormatVersion(AbstractServiceTest.FORMAT_VERSION);
    PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
    request.setPartitionValueFilters(Arrays.asList(partitionValueFilter));
    partitionValueFilter.setPartitionKey(partitionKey);
    if (startPartitionValue != null || endPartitionValue != null) {
        PartitionValueRange partitionValueRange = new PartitionValueRange();
        partitionValueFilter.setPartitionValueRange(partitionValueRange);
        partitionValueRange.setStartPartitionValue(startPartitionValue);
        partitionValueRange.setEndPartitionValue(endPartitionValue);
    }
    if (partitionValues != null) {
        partitionValueFilter.setPartitionValues(new ArrayList<>(partitionValues));
    }
    request.setBusinessObjectDataVersion(AbstractServiceTest.DATA_VERSION);
    request.setStorageName(AbstractServiceTest.STORAGE_NAME);
    request.setIncludeAllRegisteredSubPartitions(AbstractServiceTest.NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS);
    return request;
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter)

Example 19 with PartitionValueRange

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

the class BusinessObjectDataServiceTestHelper method getTestBusinessObjectDataDdlRequest.

/**
 * Creates and returns a business object data ddl request using passed parameters along with some hard-coded test values.
 *
 * @param startPartitionValue the start partition value for the partition value range
 * @param endPartitionValue the end partition value for the partition value range
 * @param partitionValues the list of partition values
 * @param customDdlName the custom DDL name
 *
 * @return the newly created business object data ddl request
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public BusinessObjectDataDdlRequest getTestBusinessObjectDataDdlRequest(String startPartitionValue, String endPartitionValue, List<String> partitionValues, String customDdlName) {
    BusinessObjectDataDdlRequest request = new BusinessObjectDataDdlRequest();
    request.setNamespace(AbstractServiceTest.NAMESPACE);
    request.setBusinessObjectDefinitionName(AbstractServiceTest.BDEF_NAME);
    request.setBusinessObjectFormatUsage(AbstractServiceTest.FORMAT_USAGE_CODE);
    request.setBusinessObjectFormatFileType(FileTypeEntity.TXT_FILE_TYPE);
    request.setBusinessObjectFormatVersion(AbstractServiceTest.FORMAT_VERSION);
    PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
    request.setPartitionValueFilters(Arrays.asList(partitionValueFilter));
    partitionValueFilter.setPartitionKey(AbstractServiceTest.FIRST_PARTITION_COLUMN_NAME);
    if (startPartitionValue != null || endPartitionValue != null) {
        PartitionValueRange partitionValueRange = new PartitionValueRange();
        partitionValueFilter.setPartitionValueRange(partitionValueRange);
        partitionValueRange.setStartPartitionValue(startPartitionValue);
        partitionValueRange.setEndPartitionValue(endPartitionValue);
    }
    if (partitionValues != null) {
        partitionValueFilter.setPartitionValues(new ArrayList(partitionValues));
    }
    request.setBusinessObjectDataVersion(AbstractServiceTest.DATA_VERSION);
    request.setStorageName(AbstractServiceTest.STORAGE_NAME);
    request.setOutputFormat(BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL);
    request.setTableName(AbstractServiceTest.TABLE_NAME);
    request.setCustomDdlName(customDdlName);
    request.setIncludeDropTableStatement(true);
    request.setIncludeIfNotExistsOption(true);
    request.setAllowMissingData(true);
    request.setIncludeAllRegisteredSubPartitions(AbstractServiceTest.NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS);
    return request;
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) ArrayList(java.util.ArrayList) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter)

Example 20 with PartitionValueRange

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesLowerCaseParameters.

@Test
public void testGetExpectedPartitionValuesLowerCaseParameters() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toUpperCase());
    // Create and persist a single test expected partition value.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE.toUpperCase()));
    // Get expected partition values for a range using relative input parameters in lower case.
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toLowerCase()), new PartitionValueRange(PARTITION_VALUE.toUpperCase(), PARTITION_VALUE.toUpperCase()));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP.toUpperCase(), Arrays.asList(PARTITION_VALUE.toUpperCase()), resultPartitionValuesInformation);
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Aggregations

PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)26 Test (org.junit.Test)19 PartitionKeyGroupKey (org.finra.herd.model.api.xml.PartitionKeyGroupKey)12 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)12 ArrayList (java.util.ArrayList)8 ExpectedPartitionValuesInformation (org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation)8 PartitionKeyGroupEntity (org.finra.herd.model.jpa.PartitionKeyGroupEntity)6 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)4 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)3 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)2 ExpectedPartitionValueEntity (org.finra.herd.model.jpa.ExpectedPartitionValueEntity)2 Predicate (javax.persistence.criteria.Predicate)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)1 BusinessObjectDataAvailability (org.finra.herd.model.api.xml.BusinessObjectDataAvailability)1 ExpectedPartitionValueInformation (org.finra.herd.model.api.xml.ExpectedPartitionValueInformation)1 ExpectedPartitionValueKey (org.finra.herd.model.api.xml.ExpectedPartitionValueKey)1 ExpectedPartitionValuesCreateRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest)1