Search in sources :

Example 11 with PartitionKeyGroupKey

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesUpperCaseParameters.

@Test
public void testGetExpectedPartitionValuesUpperCaseParameters() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toLowerCase());
    // Create and persist a single test expected partition value.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE.toLowerCase()));
    // Get expected partition values for a range using relative input parameters in upper case.
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase()), new PartitionValueRange(PARTITION_VALUE.toLowerCase(), PARTITION_VALUE.toLowerCase()));
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP.toLowerCase(), Arrays.asList(PARTITION_VALUE.toLowerCase()), resultPartitionValuesInformation);
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 12 with PartitionKeyGroupKey

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesInvalidParameters.

@Test
public void testGetExpectedPartitionValuesInvalidParameters() {
    // Try to perform a get expected partition values with the start expected partition value being greater than the end expected partition value.
    try {
        expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(PARTITION_VALUE_2, PARTITION_VALUE));
        fail("Should throw an IllegalArgumentException when the start expected partition value being greater than the end expected partition value.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The start expected partition value \"%s\" cannot be greater than the end expected partition value \"%s\".", PARTITION_VALUE_2, PARTITION_VALUE), e.getMessage());
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 13 with PartitionKeyGroupKey

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesExpectedPartitionValuesNoExist.

@Test
public void testGetExpectedPartitionValuesExpectedPartitionValuesNoExist() {
    // Create and persist a partition key group entity.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Get a range of non-existing expected partition values.
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(PARTITION_VALUE, PARTITION_VALUE_2));
    // Validate that returned object contains an empty list of expected partition values.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, new ArrayList<String>(), resultPartitionValuesInformation);
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 14 with PartitionKeyGroupKey

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

the class PartitionKeyGroupDaoTest method testGetPartitionKeyGroups.

@Test
public void testGetPartitionKeyGroups() {
    // Create and persist two partition key group entities.
    for (PartitionKeyGroupKey partitionKeyGroupKey : getTestPartitionKeyGroupKeys()) {
        partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(partitionKeyGroupKey.getPartitionKeyGroupName());
    }
    // Get the list of partition key groups.
    List<PartitionKeyGroupKey> resultPartitionKeyGroupKeys = partitionKeyGroupDao.getPartitionKeyGroups();
    // Validate the results.
    assertNotNull(resultPartitionKeyGroupKeys);
    assertTrue(resultPartitionKeyGroupKeys.containsAll(getTestPartitionKeyGroupKeys()));
}
Also used : PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 15 with PartitionKeyGroupKey

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

the class PartitionKeyGroupDaoImpl method getPartitionKeyGroups.

@Override
public List<PartitionKeyGroupKey> getPartitionKeyGroups() {
    // Create the criteria builder and the criteria.
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<PartitionKeyGroupEntity> criteria = builder.createQuery(PartitionKeyGroupEntity.class);
    // The criteria root is the partition key group.
    Root<PartitionKeyGroupEntity> partitionKeyGroupEntity = criteria.from(PartitionKeyGroupEntity.class);
    criteria.select(partitionKeyGroupEntity);
    List<PartitionKeyGroupKey> partitionKeyGroupKeys = new ArrayList<>();
    for (PartitionKeyGroupEntity entity : entityManager.createQuery(criteria).getResultList()) {
        PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey();
        partitionKeyGroupKey.setPartitionKeyGroupName(entity.getPartitionKeyGroupName());
        partitionKeyGroupKeys.add(partitionKeyGroupKey);
    }
    return partitionKeyGroupKeys;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) ArrayList(java.util.ArrayList) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey)

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