TimebasedShardingStrategy shardingStrategy = new ShardingStrategyWeekly();
int numberPerShard = 3;
long totalNumberOfObjects = 950L;
FakeIdRange subject = new FakeIdRange(CField.CDataType.TIMEUUID,startingUUID,totalNumberOfObjects,(long)numberPerShard, shardingStrategy, "testing");
Iterator<FakeIdRange.IdInRange> it = subject.getIterator(CObjectOrdering.ASCENDING);
long counter = 0;
int lastweek = -1;
int countSinceChange = 0;
while(it.hasNext()){
counter++;
FakeIdRange.IdInRange id = it.next();
DateTime dt = UuidUtil.getDateFromUUID((UUID)id.getId());
if(lastweek == -1){
//initialization case
countSinceChange = 1;
lastweek = dt.getWeekOfWeekyear();
}
else if(dt.getWeekOfWeekyear() == lastweek){
assert(countSinceChange < numberPerShard);
countSinceChange++;
}
else{
assertEquals(numberPerShard,countSinceChange);
countSinceChange=1;
};
lastweek = dt.getWeekOfWeekyear();
//System.out.println("countSinceChange = " + countSinceChange);
//System.out.println("Actual Counter = " + counter);
//System.out.println("Id Counter = " + id.getCounterValue());
//System.out.println("Counter at ID = " + subject.getCounterAtId(id.getId()));
//System.out.println("Date on UUID is: " + UuidUtil.getDateFromUUID((UUID)id.getId()));
assertEquals(subject.getCounterAtId(id.getId()), id.getCounterValue());
}
assertEquals(totalNumberOfObjects,counter);
}