Search in sources :

Example 21 with PartitionValueRange

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesMissingOptionalParameters.

@Test
public void testGetExpectedPartitionValuesMissingOptionalParameters() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Create and persist a list of test expected partition values.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    // Get the sorted list of test expected partition values.
    List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
    int startExpectedPartitionValueIndex = 1;
    int endExpectedPartitionValueIndex = testSortedExpectedPartitionValues.size() - 2;
    ExpectedPartitionValuesInformation resultPartitionValuesInformation;
    // Get expected partition values for a range without specifying the end expected partition value.
    resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex), BLANK_TEXT));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(startExpectedPartitionValueIndex, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues().size()), resultPartitionValuesInformation);
    // Get expected partition values for a range without specifying the start expected partition value.
    resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(BLANK_TEXT, testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex)));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(0, endExpectedPartitionValueIndex + 1), 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)

Example 22 with PartitionValueRange

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesPartitionKeyGroupNoExists.

@Test
public void testGetExpectedPartitionValuesPartitionKeyGroupNoExists() {
    // Try to perform a get expected partition values using a non-existing partition key group name.
    String partitionKeyGroupName = "I_DO_NOT_EXIST";
    try {
        expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(partitionKeyGroupName), new PartitionValueRange(PARTITION_VALUE, PARTITION_VALUE));
        fail("Should throw an IllegalArgumentException when partition key group does not exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Partition key group \"%s\" doesn't exist.", partitionKeyGroupName), e.getMessage());
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 23 with PartitionValueRange

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesMissingRequiredParameters.

@Test
public void testGetExpectedPartitionValuesMissingRequiredParameters() {
    // Try to perform a get expected partition values without specifying partition key group name.
    try {
        expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(BLANK_TEXT), new PartitionValueRange(PARTITION_VALUE, PARTITION_VALUE));
        fail("Should throw an IllegalArgumentException when partition key group is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition key group name must be specified.", e.getMessage());
    }
    // Try to perform a get expected partition values without specifying neither start or end expected partition values for the range.
    try {
        expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(BLANK_TEXT, BLANK_TEXT));
        fail("Should throw an IllegalArgumentException when both start and end expected partition values are not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least one start or end expected partition value must be specified.", e.getMessage());
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 24 with PartitionValueRange

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesTrimParameters.

@Test
public void testGetExpectedPartitionValuesTrimParameters() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Create and persist a list of test expected partition values.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    // Get expected partition values for a range with request parameters padded with whitespace characters.
    List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(addWhitespace(PARTITION_KEY_GROUP)), new PartitionValueRange(addWhitespace(testSortedExpectedPartitionValues.get(0)), addWhitespace(testSortedExpectedPartitionValues.get(testSortedExpectedPartitionValues.size() - 1))));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, 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)

Example 25 with PartitionValueRange

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

the class ExpectedPartitionValueServiceTest method testLargeNumberOfExpectedPartitionValues.

@Test
public void testLargeNumberOfExpectedPartitionValues() {
    // Define some constants.
    final int MAX_PARTITION_VALUES = 1000;
    final int LAST_ELEMENT_INDEX = MAX_PARTITION_VALUES - 1;
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Add expected partition values to this partition key group.
    List<String> testUnsortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues(MAX_PARTITION_VALUES);
    List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(MAX_PARTITION_VALUES);
    ExpectedPartitionValuesCreateRequest createRequest = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, testUnsortedExpectedPartitionValues);
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.createExpectedPartitionValues(createRequest);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, resultPartitionValuesInformation);
    // Validate that the expected partition value entities got created.
    assertEquals(testUnsortedExpectedPartitionValues.size(), partitionKeyGroupEntity.getExpectedPartitionValues().size());
    // Get expected partition value without an offset.
    ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(MAX_PARTITION_VALUES / 2)), null);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(MAX_PARTITION_VALUES / 2), resultPartitionValueInformation);
    // Get expected partition value by passing a large positive offset.
    resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(0)), LAST_ELEMENT_INDEX);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(LAST_ELEMENT_INDEX), resultPartitionValueInformation);
    // Get expected partition value by passing a large negative offset.
    resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(LAST_ELEMENT_INDEX)), -LAST_ELEMENT_INDEX);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(0), resultPartitionValueInformation);
    // Get a range of expected partition values.
    resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(testSortedExpectedPartitionValues.get(0), testSortedExpectedPartitionValues.get(LAST_ELEMENT_INDEX)));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, resultPartitionValuesInformation);
    // Delete expected partition values from this partition key group.
    ExpectedPartitionValuesDeleteRequest deleteRequest = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, testUnsortedExpectedPartitionValues);
    ExpectedPartitionValuesInformation deleteResultPartitionValuesInformation = expectedPartitionValueService.deleteExpectedPartitionValues(deleteRequest);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, deleteResultPartitionValuesInformation);
    // Validate that the expected partition value entities got deleted.
    assertEquals(0, partitionKeyGroupEntity.getExpectedPartitionValues().size());
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) ExpectedPartitionValueInformation(org.finra.herd.model.api.xml.ExpectedPartitionValueInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) ExpectedPartitionValueKey(org.finra.herd.model.api.xml.ExpectedPartitionValueKey) 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