PrimaryIndexBucketLocatorImpl implements BucketLocator { protected static Long convertBinaryBase64ToLong(String binaryBase64) throws IllegalArgumentException { if (binaryBase64 == null) { return null; } if (binaryBase64.length() < 4) { throw new IllegalArgumentException("Input is not a valid BinaryBase64 value, minimum length of BinaryBase64 is 4. Enter a valid value"); } String first8Chars = null; if (binaryBase64.length() >= 8) { first8Chars = binaryBase64.substring(0, 8); } else { first8Chars = binaryBase64; int toPad = 8 - first8Chars.length(); for (int i = 0; i < toPad; i++) { first8Chars += '\u0000'; } } byte[] bytes = first8Chars.getBytes(); return ByteBuffer.wrap(bytes).getLong(); } 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 testBinaryBase64ToLong() { logger.debug("Test to convertBinaryBase64ToLong"); String binaryBase641 = "kkkk"; String binaryBase642 = "oooooooooooooooo"; String binaryBase643 = "wwwwwwwwwwwwwwwwwwww"; String binaryBase64Duplicate = "oooooooooooooooo"; String binaryBase644 = "kkkkkkkk"; Long firstBinLongVal = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(binaryBase641); Long secondBinLongVal = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(binaryBase642); Long thirdBinLongVal = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(binaryBase643); Long binaryBase64Dupl = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(binaryBase64Duplicate); assertTrue("First binaryBase64 String should be less than the second one", firstBinLongVal < secondBinLongVal); assertTrue("Second binaryBase64 String should be less than the third one", secondBinLongVal < thirdBinLongVal); assertEquals("Duplicate input values should return the same output Long value", secondBinLongVal, binaryBase64Dupl); Long fourthBinLongVal = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(binaryBase644); assertTrue("Forth binaryBase64 String should be greater than the first one", fourthBinLongVal > firstBinLongVal); }
@Test public void testBinaryBase64ToLongException() { logger.debug("test to converBinaryBase64ToLong with Exception"); boolean expectedExceptionThrown = false; try { PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong("jf"); } catch (IllegalArgumentException ex) { expectedExceptionThrown = true; } assertTrue("Expected exception thrown. ", expectedExceptionThrown); }
@Test public void testBinaryBase64ToLongNull() { logger.debug("Test to converBinaryBase64ToLong with null value"); Long testLongNull = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(null); assertTrue("null values sent is not null", testLongNull == null); }
@Test @Ignore public void testConvertBinaryBase64ToLong() { System.out.println("convertBinaryBase64ToLong"); String binaryBase64 = ""; Long expResult = null; Long result = PrimaryIndexBucketLocatorImpl.convertBinaryBase64ToLong(binaryBase64); assertEquals(expResult, result); }