use of org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest in project herd by FINRAOS.
the class ExpectedPartitionValueRestControllerTest method testDeleteExpectedPartitionValues.
@Test
public void testDeleteExpectedPartitionValues() {
ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues());
// Delete expected partition values from this partition key group.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
when(expectedPartitionValueService.deleteExpectedPartitionValues(request)).thenReturn(expectedPartitionValuesInformation);
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueRestController.deleteExpectedPartitionValues(request);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
// Verify the external calls.
verify(expectedPartitionValueService).deleteExpectedPartitionValues(request);
verifyNoMoreInteractions(expectedPartitionValueService);
// Validate the returned object.
assertEquals(expectedPartitionValuesInformation, resultPartitionValuesInformation);
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesPartitionKeyGroupNoExists.
@Test
public void testDeleteExpectedPartitionValuesPartitionKeyGroupNoExists() {
// Try to perform a delete using a non-existing partition key group name.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest("I_DO_NOT_EXIST", expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
try {
expectedPartitionValueService.deleteExpectedPartitionValues(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.ExpectedPartitionValuesDeleteRequest in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesExpectedPartitionValueNoExists.
@Test
public void testDeleteExpectedPartitionValuesExpectedPartitionValueNoExists() {
// Create and persist a partition key group entity.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Try to delete a non-existing expected partition value.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, Arrays.asList("I_DO_NOT_EXIST"));
try {
expectedPartitionValueService.deleteExpectedPartitionValues(request);
fail("Should throw an IllegalArgumentException when any of the expected partition values do not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Expected partition value \"%s\" doesn't exist in \"%s\" partition key group.", request.getExpectedPartitionValues().get(0), PARTITION_KEY_GROUP), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValues.
@Test
public void testDeleteExpectedPartitionValues() {
// 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.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
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());
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesDuplicatePartitionValues.
@Test
public void testDeleteExpectedPartitionValuesDuplicatePartitionValues() {
// Try to perform a delete by passing duplicate expected partition values.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, Arrays.asList(PARTITION_VALUE, PARTITION_VALUE));
try {
expectedPartitionValueService.deleteExpectedPartitionValues(request);
fail("Should throw an IllegalArgumentException when delete request contains duplicate expected partition values.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Duplicate expected partition value \"%s\" found.", PARTITION_VALUE), e.getMessage());
}
}
Aggregations