Search in sources :

Example 1 with ExpectedPartitionValuesDeleteRequest

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);
}
Also used : ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

Example 2 with ExpectedPartitionValuesDeleteRequest

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

Example 3 with ExpectedPartitionValuesDeleteRequest

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

Example 4 with ExpectedPartitionValuesDeleteRequest

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());
}
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 5 with ExpectedPartitionValuesDeleteRequest

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());
    }
}
Also used : ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

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