PrimaryIndexBucketLocatorImpl implements BucketLocator { protected static Long convertUuidToLong(UUID uuid) { if (uuid == null) { return null; } Long convertedUuid; if (uuid.version() == 1) { convertedUuid = uuid.timestamp(); } else { convertedUuid = uuid.getMostSignificantBits(); } return convertedUuid; } 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 testconvertUUIDToLong() { logger.debug("Convert UUID to Long"); UUID type4Uuid = UUID.randomUUID(); UUID type4Uuid2 = UUID.randomUUID(); String uuidInStr = "123e4567-e89b-12d3-a456-426655440000"; UUID type1Uuid = UUID.fromString(uuidInStr); Long outType4Val1 = PrimaryIndexBucketLocatorImpl.convertUuidToLong(type4Uuid); Long outType4Val2 = PrimaryIndexBucketLocatorImpl.convertUuidToLong(type4Uuid2); Long outType1Val3 = PrimaryIndexBucketLocatorImpl.convertUuidToLong(type1Uuid); assertTrue(outType4Val1 + "is different from outType4Val2", !outType4Val1.equals(outType4Val2)); assertTrue(outType1Val3 + "is different from outType4Val1", !outType1Val3.equals(outType4Val1)); }
@Test public void testUUIDToLongTimestamp() { String uuidInStr1 = "123e4567-e87b-12d3-a456-426655440000"; UUID uuid1 = UUID.fromString(uuidInStr1); Long timestampOfUuid1 = PrimaryIndexBucketLocatorImpl.convertUuidToLong(uuid1); Long timestampOfUuid11 = uuid1.timestamp(); assertEquals(timestampOfUuid1, timestampOfUuid11); String uuidInStr2 = "123e4567-e89b-12d3-a456-426655440000"; UUID recentUuid = UUID.fromString(uuidInStr2); Long timestampOfrecentUuid1 = recentUuid.timestamp(); assertTrue(timestampOfUuid1 + " is different from timestampOfUuid2", !timestampOfUuid11.equals(timestampOfrecentUuid1)); assertTrue("Timestamp of recent UUID should be greater then the old uuid", timestampOfUuid11 < timestampOfrecentUuid1); }
@Test public void testUuidToLongNull() { logger.debug("Test to converUuidToLong with null value"); Long testLongNull = PrimaryIndexBucketLocatorImpl.convertUuidToLong(null); assertTrue("null values sent is not null", testLongNull == null); }
@Test @Ignore public void testConvertUuidToLong() { System.out.println("convertUuidToLong"); UUID uuid = null; Long expResult = null; Long result = PrimaryIndexBucketLocatorImpl.convertUuidToLong(uuid); assertEquals(expResult, result); }