PrimaryIndexBucketLocatorImpl implements BucketLocator { protected static Long convertDoubleToLong(Double inDoubleValue) { if (inDoubleValue == null) { return null; } if(inDoubleValue > Long.MAX_VALUE){ return Long.MAX_VALUE; } if(inDoubleValue < Long.MIN_VALUE){ return Long.MIN_VALUE; } Long outLongValue = Math.round(inDoubleValue); return outLongValue; } 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 testDoubleToLongNullValues() { logger.debug("convert Double to long with null values"); assertNull("the value is not null as expected ", PrimaryIndexBucketLocatorImpl.convertDoubleToLong(null)); }
@Test public void testConvertDoubleToLong() { logger.debug("convert Double to long"); Double d = Double.MAX_VALUE; Long result = PrimaryIndexBucketLocatorImpl.convertDoubleToLong(d); assertNearMaxLongValue(result); d = 0.0; result = PrimaryIndexBucketLocatorImpl.convertDoubleToLong(d); assertNearZeroLongValue(result); d = (double) (Double.MAX_VALUE * -1); result = PrimaryIndexBucketLocatorImpl.convertDoubleToLong(d); assertNearMinLongValue(result); assertTrue("Function not monotonically increasing.", PrimaryIndexBucketLocatorImpl.convertDoubleToLong(1.0) < PrimaryIndexBucketLocatorImpl.convertDoubleToLong(2.0)); assertTrue("Function not monotonically increasing.", PrimaryIndexBucketLocatorImpl.convertDoubleToLong(2.0) < PrimaryIndexBucketLocatorImpl.convertDoubleToLong(3.0)); assertTrue("Function not monotonically increasing.", PrimaryIndexBucketLocatorImpl.convertDoubleToLong(-2.0) < PrimaryIndexBucketLocatorImpl.convertDoubleToLong(-1.0)); assertTrue("Function not monotonically increasing.", PrimaryIndexBucketLocatorImpl.convertDoubleToLong(-900000000000.0) < PrimaryIndexBucketLocatorImpl.convertDoubleToLong(-1.0)); }