PrimaryIndexBucketLocatorImpl implements BucketLocator { protected static Long convertDateToBucketingLong(Date dateToBeConverted) { if (dateToBeConverted == null) { return null; } return dateToBeConverted.getTime(); } private  PrimaryIndexBucketLocatorImpl(); @Deprecated  PrimaryIndexBucketLocatorImpl(List<Long> textBuckets, List<Long> dateTimeBuckets,
            List<Long> doubleBuckets, List<Long> integerBuckets, List<Long> booleanBuckets,
            List<Long> uuidBuckets, List<Long> binaryBuckets, List<Long> longBuckets, List<Long> timepointBuckets); static PrimaryIndexBucketLocatorImpl getInstance(); @Override Long getBucket(Object bucketingObject, FieldDataType dataType); static Long convertObjectToBucketingToken(Object toBeConverted, FieldDataType dataType); static List<Long>[] getBUCKETS();  }
@Test public void testConvertDateToBucketingLong() throws Exception { Date result = ParseUtils.parseStringAsDate("Sun, 15 Jun 2014 22:31:42 GMT"); long time1 = PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(result); long time2 = PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss z").parse("06/15/2014 22:31:42 GMT")); assertTrue("the times are not equal", time1 == time2); }
@Test public void testDateToLongCompareTimes() throws Exception { Date testDate = new Date(); String in = testDate.toString(); Date currentTime = ParseUtils.parseStringAsDate(in); long timeCurrent = PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(currentTime); Date result = ParseUtils.parseStringAsDate("Mon Jun 15 22:24:54 GMT 2015"); long time1 = PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(result); assertTrue("time1 is not less than timeCurrent" + time1 + "<" + timeCurrent, time1 < timeCurrent); Date resultFuture = ParseUtils.parseStringAsDate("6/6/2115"); long timeFuture = PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(resultFuture); assertTrue("current time is not less than future time" + timeCurrent + "<" + timeFuture, timeCurrent < timeFuture); Date resultAncient = ParseUtils.parseStringAsDate("9/9/1000"); long timeAncient = PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(resultAncient); assertTrue("ancient time is not less than current time", timeAncient < timeCurrent); }
@Test public void testDateToLongNull() { assertNull("the value is not null as expected", PrimaryIndexBucketLocatorImpl.convertDateToBucketingLong(null)); }