Search in sources :

Example 1 with PartitionKeyGroupKey

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

the class PartitionKeyGroupRestControllerTest method testCreatePartitionKeyGroup.

@Test
public void testCreatePartitionKeyGroup() {
    // Create a partition key group.
    PartitionKeyGroup partitionKeyGroup = new PartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP));
    PartitionKeyGroupCreateRequest request = partitionKeyGroupServiceTestHelper.createPartitionKeyGroupCreateRequest(PARTITION_KEY_GROUP);
    when(partitionKeyGroupService.createPartitionKeyGroup(request)).thenReturn(partitionKeyGroup);
    PartitionKeyGroup resultPartitionKeyGroup = partitionKeyGroupRestController.createPartitionKeyGroup(request);
    // Validate the returned object.
    partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, resultPartitionKeyGroup);
    // Verify the external calls.
    verify(partitionKeyGroupService).createPartitionKeyGroup(request);
    verifyNoMoreInteractions(partitionKeyGroupService);
    // Validate the returned object.
    assertEquals(partitionKeyGroup, resultPartitionKeyGroup);
}
Also used : PartitionKeyGroup(org.finra.herd.model.api.xml.PartitionKeyGroup) PartitionKeyGroupCreateRequest(org.finra.herd.model.api.xml.PartitionKeyGroupCreateRequest) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 2 with PartitionKeyGroupKey

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

the class ExpectedPartitionValueServiceImpl method createExpectedPartitionValuesInformationFromEntities.

/**
 * Creates the expected partition values information from the persisted entities.
 *
 * @param partitionKeyGroupEntity the partition key group entity
 * @param expectedPartitionValueEntities the list of expected partition value entities
 *
 * @return the expected partition values information
 */
private ExpectedPartitionValuesInformation createExpectedPartitionValuesInformationFromEntities(PartitionKeyGroupEntity partitionKeyGroupEntity, Collection<ExpectedPartitionValueEntity> expectedPartitionValueEntities) {
    // Create an expected partition values information instance.
    ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation();
    // Add the partition key group key.
    PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey();
    expectedPartitionValuesInformation.setPartitionKeyGroupKey(partitionKeyGroupKey);
    partitionKeyGroupKey.setPartitionKeyGroupName(partitionKeyGroupEntity.getPartitionKeyGroupName());
    // Add the expected partition values.
    List<String> expectedPartitionValues = new ArrayList<>();
    expectedPartitionValuesInformation.setExpectedPartitionValues(expectedPartitionValues);
    for (ExpectedPartitionValueEntity expectedPartitionValueEntity : expectedPartitionValueEntities) {
        expectedPartitionValues.add(expectedPartitionValueEntity.getPartitionValue());
    }
    return expectedPartitionValuesInformation;
}
Also used : ExpectedPartitionValueEntity(org.finra.herd.model.jpa.ExpectedPartitionValueEntity) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) ArrayList(java.util.ArrayList) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey)

Example 3 with PartitionKeyGroupKey

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

the class PartitionKeyGroupDaoTest method testGetPartitionKeyGroupByKey.

@Test
public void testGetPartitionKeyGroupByKey() {
    // Create relative database entities.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Retrieve partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDao.getPartitionKeyGroupByKey(new PartitionKeyGroupKey(PARTITION_KEY_GROUP));
    // Validate the results.
    assertNotNull(partitionKeyGroupEntity);
    assertTrue(partitionKeyGroupEntity.getPartitionKeyGroupName().equals(PARTITION_KEY_GROUP));
}
Also used : PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 4 with PartitionKeyGroupKey

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

the class PartitionKeyGroupServiceTest method testGetPartitionKeyGroup.

@Test
public void testGetPartitionKeyGroup() {
    // Create and persist a partition key group entity.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Retrieve the partition key group.
    PartitionKeyGroup resultPartitionKeyGroup = partitionKeyGroupService.getPartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP));
    // Validate the returned object.
    partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP, resultPartitionKeyGroup);
}
Also used : PartitionKeyGroup(org.finra.herd.model.api.xml.PartitionKeyGroup) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 5 with PartitionKeyGroupKey

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

the class PartitionKeyGroupServiceTest method testDeletePartitionKeyGroupLowerCaseParameters.

@Test
public void testDeletePartitionKeyGroupLowerCaseParameters() {
    // Create and persist a partition key group entity with an uppercase name.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toUpperCase());
    // Validate that this partition key group exists.
    partitionKeyGroupService.getPartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase()));
    // Retrieve the partition key group by passing partition key group name in lower case.
    PartitionKeyGroup deletedPartitionKeyGroup = partitionKeyGroupService.deletePartitionKeyGroup(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toLowerCase()));
    // Validate the returned object.
    partitionKeyGroupServiceTestHelper.validatePartitionKeyGroup(PARTITION_KEY_GROUP.toUpperCase(), deletedPartitionKeyGroup);
    // Ensure that this partition key group is no longer there.
    assertNull(partitionKeyGroupDao.getPartitionKeyGroupByKey(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase())));
}
Also used : PartitionKeyGroup(org.finra.herd.model.api.xml.PartitionKeyGroup) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Aggregations

PartitionKeyGroupKey (org.finra.herd.model.api.xml.PartitionKeyGroupKey)36 Test (org.junit.Test)29 PartitionKeyGroup (org.finra.herd.model.api.xml.PartitionKeyGroup)13 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)12 ExpectedPartitionValuesInformation (org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation)9 PartitionKeyGroupEntity (org.finra.herd.model.jpa.PartitionKeyGroupEntity)9 Secured (org.springframework.security.access.annotation.Secured)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ArrayList (java.util.ArrayList)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)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 ExpectedPartitionValuesCreateRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest)1 ExpectedPartitionValuesDeleteRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest)1 PartitionKeyGroupCreateRequest (org.finra.herd.model.api.xml.PartitionKeyGroupCreateRequest)1 PartitionKeyGroupKeys (org.finra.herd.model.api.xml.PartitionKeyGroupKeys)1 ExpectedPartitionValueEntity (org.finra.herd.model.jpa.ExpectedPartitionValueEntity)1