use of org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucket in project lispflowmapping by opendaylight.
the class TimeBucketWheelUnitTest method mappingRefreshedProperlyTest.
/**
* Tests {@link TimeBucketWheel#refreshMappping(Eid, MappingData, long, int)} method.
* {@link ClassCastException} can be thrown.
*/
@Test
public void mappingRefreshedProperlyTest() {
PowerMockito.mockStatic(System.class);
long frozenTimeStamp = System.currentTimeMillis();
PowerMockito.when(System.currentTimeMillis()).thenReturn(frozenTimeStamp);
TimeBucketWheel timeBucketWheel = getDefaultTimeBucketWheel();
final int bucketId1 = timeBucketWheel.add(IPV4_EID_1, getDefaultMappingData(IPV4_EID_1), System.currentTimeMillis());
frozenTimeStamp += 2000;
PowerMockito.when(System.currentTimeMillis()).thenReturn(frozenTimeStamp);
MappingData newMappingData = getDefaultMappingData(IPV4_EID_1);
int currentBucketId = timeBucketWheel.refreshMappping(IPV4_EID_1, newMappingData, System.currentTimeMillis(), bucketId1);
List<TimeBucket> bucketList = extractBucketList(timeBucketWheel);
TimeBucket pastTimeBucket = bucketList.get(bucketId1);
MappingData oldStoredMappingData = getMappingDataFromTimeBucket(pastTimeBucket, IPV4_EID_1);
Assert.assertNull(oldStoredMappingData);
TimeBucket presentTimeBucket = bucketList.get(currentBucketId);
MappingData newStoredMappingData = getMappingDataFromTimeBucket(presentTimeBucket, IPV4_EID_1);
Assert.assertEquals(newMappingData, newStoredMappingData);
}
Aggregations