Search in sources :

Example 6 with ExpectedPartitionValuesDeleteRequest

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

the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesMissingRequiredParameters.

@Test
public void testDeleteExpectedPartitionValuesMissingRequiredParameters() {
    ExpectedPartitionValuesDeleteRequest request;
    // Try to perform a delete without specifying partition key group name.
    request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(BLANK_TEXT, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    try {
        expectedPartitionValueService.deleteExpectedPartitionValues(request);
        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 delete without specifying any expected partition values.
    request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, new ArrayList<String>());
    try {
        expectedPartitionValueService.deleteExpectedPartitionValues(request);
        fail("Should throw an IllegalArgumentException when no expected partition values are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least one expected partition value must be specified.", e.getMessage());
    }
    // Try to perform a delete with a missing expected partition value.
    request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, Arrays.asList(BLANK_TEXT));
    try {
        expectedPartitionValueService.deleteExpectedPartitionValues(request);
        fail("Should throw an IllegalArgumentException when expected partition value is missing.");
    } catch (IllegalArgumentException e) {
        assertEquals("An expected partition value must be specified.", e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

Example 7 with ExpectedPartitionValuesDeleteRequest

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

the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesTrimParameters.

@Test
public void testDeleteExpectedPartitionValuesTrimParameters() {
    // 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());
    // Delete expected partition values from this partition key group with request parameters padded with whitespace characters.
    ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(addWhitespace(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    for (int i = 0; i < request.getExpectedPartitionValues().size(); i++) {
        request.getExpectedPartitionValues().set(i, addWhitespace(request.getExpectedPartitionValues().get(i)));
    }
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.deleteExpectedPartitionValues(request);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
    // Validate that the expected partition value entities got deleted.
    assertEquals(0, partitionKeyGroupEntity.getExpectedPartitionValues().size());
}
Also used : ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

Example 8 with ExpectedPartitionValuesDeleteRequest

use of org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest 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)

Example 9 with ExpectedPartitionValuesDeleteRequest

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

the class ExpectedPartitionValueServiceTestHelper method createExpectedPartitionValuesDeleteRequest.

/**
 * Creates an expected partition values delete request.
 *
 * @param partitionKeyGroupName the partition key group name
 * @param expectedPartitionValues the list of expected partition values
 *
 * @return the expected partition values delete request
 */
public ExpectedPartitionValuesDeleteRequest createExpectedPartitionValuesDeleteRequest(String partitionKeyGroupName, List<String> expectedPartitionValues) {
    ExpectedPartitionValuesDeleteRequest expectedPartitionValuesDeleteRequest = new ExpectedPartitionValuesDeleteRequest();
    expectedPartitionValuesDeleteRequest.setPartitionKeyGroupKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(partitionKeyGroupName));
    expectedPartitionValuesDeleteRequest.setExpectedPartitionValues(expectedPartitionValues);
    return expectedPartitionValuesDeleteRequest;
}
Also used : ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest)

Aggregations

ExpectedPartitionValuesDeleteRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest)9 Test (org.junit.Test)8 ExpectedPartitionValuesInformation (org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation)4 PartitionKeyGroupEntity (org.finra.herd.model.jpa.PartitionKeyGroupEntity)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 ArrayList (java.util.ArrayList)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 PartitionKeyGroupKey (org.finra.herd.model.api.xml.PartitionKeyGroupKey)1 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)1