/** * Creates a map that maps expected partition values to the relative expected partition value entities. * * @param expectedPartitionValueEntities the collection of expected partition value entities to be loaded into the map * * @return the map that maps expected partition values to the relative expected partition value entities */ private Map<String, ExpectedPartitionValueEntity> getExpectedPartitionValueEntityMap( Collection<ExpectedPartitionValueEntity> expectedPartitionValueEntities) { Map<String, ExpectedPartitionValueEntity> expectedPartitionValueEntityMap = new HashMap<>(); for (ExpectedPartitionValueEntity expectedPartitionValueEntity : expectedPartitionValueEntities) { expectedPartitionValueEntityMap.put(expectedPartitionValueEntity.getPartitionValue(), expectedPartitionValueEntity); } return expectedPartitionValueEntityMap; }
/** * Creates a map that maps expected partition values to the relative expected partition value entities. * * @param expectedPartitionValueEntities the collection of expected partition value entities to be loaded into the map * * @return the map that maps expected partition values to the relative expected partition value entities */ private Map<String, ExpectedPartitionValueEntity> getExpectedPartitionValueEntityMap( Collection<ExpectedPartitionValueEntity> expectedPartitionValueEntities) { Map<String, ExpectedPartitionValueEntity> expectedPartitionValueEntityMap = new HashMap<>(); for (ExpectedPartitionValueEntity expectedPartitionValueEntity : expectedPartitionValueEntities) { expectedPartitionValueEntityMap.put(expectedPartitionValueEntity.getPartitionValue(), expectedPartitionValueEntity); } return expectedPartitionValueEntityMap; }
String partitionValue = expectedPartitionValueEntity.getPartitionValue();
String partitionValue = expectedPartitionValueEntity.getPartitionValue();
expectedPartitionValues.add(expectedPartitionValueEntity.getPartitionValue());
expectedPartitionValues.add(expectedPartitionValueEntity.getPartitionValue());
@Test public void testGetExpectedPartitionValue() { // 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()); // Get expected partition value for different offset values. List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(); int testExpectedPartitionValueIndex = 3; for (Integer offset : Arrays.asList(-2, 0, 2)) { ExpectedPartitionValueEntity resultExpectedPartitionValueEntity = expectedPartitionValueDao.getExpectedPartitionValue( new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex)), offset); // Validate the returned object. resultExpectedPartitionValueEntity.getPartitionValue().equals(testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex + offset)); } }
/** * Creates the expected partition value information from the persisted entity. * * @param expectedPartitionValueEntity the expected partition value entity * * @return the expected partition value information */ private ExpectedPartitionValueInformation createExpectedPartitionValueInformationFromEntity(ExpectedPartitionValueEntity expectedPartitionValueEntity) { // Create an expected partition values information instance. ExpectedPartitionValueInformation expectedPartitionValueInformation = new ExpectedPartitionValueInformation(); // Add the expected partition value key. ExpectedPartitionValueKey expectedPartitionValueKey = new ExpectedPartitionValueKey(); expectedPartitionValueInformation.setExpectedPartitionValueKey(expectedPartitionValueKey); expectedPartitionValueKey.setPartitionKeyGroupName(expectedPartitionValueEntity.getPartitionKeyGroup().getPartitionKeyGroupName()); expectedPartitionValueKey.setExpectedPartitionValue(expectedPartitionValueEntity.getPartitionValue()); return expectedPartitionValueInformation; }
/** * Test DAO method to retrieve expected partition values by range. */ @Test public void testGetExpectedPartitionValuesByGroupAndRange() { expectedPartitionValueDaoTestHelper.createExpectedPartitionValueProcessDatesForApril2014(PARTITION_KEY_GROUP); PartitionValueRange partitionValueRange = new PartitionValueRange(); partitionValueRange.setStartPartitionValue(getDateAsString(2014, 3, 11)); partitionValueRange.setEndPartitionValue(getDateAsString(2014, 3, 17)); List<ExpectedPartitionValueEntity> expectedPartitionValueEntities = expectedPartitionValueDao.getExpectedPartitionValuesByGroupAndRange(PARTITION_KEY_GROUP, partitionValueRange); assertEquals(expectedPartitionValueEntities.size(), 5, expectedPartitionValueEntities.size()); assertEquals(expectedPartitionValueEntities.get(0).getPartitionValue(), getDateAsString(2014, 3, 11)); assertEquals(expectedPartitionValueEntities.get(1).getPartitionValue(), getDateAsString(2014, 3, 14)); assertEquals(expectedPartitionValueEntities.get(2).getPartitionValue(), getDateAsString(2014, 3, 15)); assertEquals(expectedPartitionValueEntities.get(3).getPartitionValue(), getDateAsString(2014, 3, 16)); assertEquals(expectedPartitionValueEntities.get(4).getPartitionValue(), getDateAsString(2014, 3, 17)); }
/** * Creates the expected partition value information from the persisted entity. * * @param expectedPartitionValueEntity the expected partition value entity * * @return the expected partition value information */ private ExpectedPartitionValueInformation createExpectedPartitionValueInformationFromEntity(ExpectedPartitionValueEntity expectedPartitionValueEntity) { // Create an expected partition values information instance. ExpectedPartitionValueInformation expectedPartitionValueInformation = new ExpectedPartitionValueInformation(); // Add the expected partition value key. ExpectedPartitionValueKey expectedPartitionValueKey = new ExpectedPartitionValueKey(); expectedPartitionValueInformation.setExpectedPartitionValueKey(expectedPartitionValueKey); expectedPartitionValueKey.setPartitionKeyGroupName(expectedPartitionValueEntity.getPartitionKeyGroup().getPartitionKeyGroupName()); expectedPartitionValueKey.setExpectedPartitionValue(expectedPartitionValueEntity.getPartitionValue()); return expectedPartitionValueInformation; }