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());
}
}
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());
}
}
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());
}
}
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);
}
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;
}
Aggregations