Search in sources :

Example 1 with ExpectedPartitionValuesCreateRequest

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

the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesMissingRequiredParameters.

@Test
public void testCreateExpectedPartitionValuesMissingRequiredParameters() {
    ExpectedPartitionValuesCreateRequest request;
    // Try to perform a create without specifying partition key group name.
    request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(BLANK_TEXT, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    try {
        expectedPartitionValueService.createExpectedPartitionValues(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 create without specifying any expected partition values.
    request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, new ArrayList<String>());
    try {
        expectedPartitionValueService.createExpectedPartitionValues(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 create with a missing expected partition value.
    request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, Arrays.asList(BLANK_TEXT));
    try {
        expectedPartitionValueService.createExpectedPartitionValues(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) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) Test(org.junit.Test)

Example 2 with ExpectedPartitionValuesCreateRequest

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

the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesExpectedPartitionValueAlreadyExists.

@Test
public void testCreateExpectedPartitionValuesExpectedPartitionValueAlreadyExists() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Create and persist a single test expected partition value.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE));
    // Try to perform a create using an already existing expected partition value.
    ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, Arrays.asList(PARTITION_VALUE));
    try {
        expectedPartitionValueService.createExpectedPartitionValues(request);
        fail("Should throw an AlreadyExistsException when expected partition value already exists.");
    } catch (AlreadyExistsException e) {
        assertEquals(String.format("Expected partition value \"%s\" already exists in \"%s\" partition key group.", PARTITION_VALUE, PARTITION_KEY_GROUP), e.getMessage());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) Test(org.junit.Test)

Example 3 with ExpectedPartitionValuesCreateRequest

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

the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesPartitionKeyGroupNoExists.

@Test
public void testCreateExpectedPartitionValuesPartitionKeyGroupNoExists() {
    // Try to perform a create using a non-existing partition key group name.
    ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest("I_DO_NOT_EXIST", expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    try {
        expectedPartitionValueService.createExpectedPartitionValues(request);
        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.", request.getPartitionKeyGroupKey().getPartitionKeyGroupName()), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) Test(org.junit.Test)

Example 4 with ExpectedPartitionValuesCreateRequest

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

the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesTrimParameters.

@Test
public void testCreateExpectedPartitionValuesTrimParameters() {
    // Create and persist a partition key group entity.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Add expected partition values to this partition key group with request parameters padded with whitespace characters.
    ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(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.createExpectedPartitionValues(request);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
}
Also used : ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) Test(org.junit.Test)

Example 5 with ExpectedPartitionValuesCreateRequest

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

the class ExpectedPartitionValueServiceTestHelper method createExpectedPartitionValuesCreateRequest.

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

Aggregations

ExpectedPartitionValuesCreateRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest)9 Test (org.junit.Test)8 ExpectedPartitionValuesInformation (org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation)4 PartitionKeyGroupEntity (org.finra.herd.model.jpa.PartitionKeyGroupEntity)2 ArrayList (java.util.ArrayList)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 ExpectedPartitionValueInformation (org.finra.herd.model.api.xml.ExpectedPartitionValueInformation)1 ExpectedPartitionValueKey (org.finra.herd.model.api.xml.ExpectedPartitionValueKey)1 ExpectedPartitionValuesDeleteRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest)1 PartitionKeyGroupKey (org.finra.herd.model.api.xml.PartitionKeyGroupKey)1 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)1