PrimaryIndexBucketLocatorImpl implements BucketLocator { protected static Long convertStringToBuckectingLong(String stringToBeConverted) { if (stringToBeConverted == null || stringToBeConverted.equals("")) { return null; } byte[] byteString = stringToBeConverted.getBytes(); if (byteString.length < 8) { byte[] newByteString = new byte[8]; for (int i = 0; i < newByteString.length; i++) { if (i < byteString.length) { newByteString[i] = byteString[i]; } else { newByteString[i] = 0; } } byteString = newByteString; } ByteBuffer bb = ByteBuffer.wrap(byteString); long byteMethod = bb.getLong(); byteMethod = Math.abs(byteMethod); return byteMethod; } 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 testStringToLongNull() { Long testLong = PrimaryIndexBucketLocatorImpl.convertStringToBuckectingLong(null); assertTrue("null values sent is not null", testLong == null); Long testLong1 = PrimaryIndexBucketLocatorImpl.convertStringToBuckectingLong(""); assertTrue("blank string sent is not null", testLong1 == null); }
@Test public void testConvertStringToLong() { logger.debug("convert string to long test"); String[] testString = new String[15]; Long[] testLong = new Long[15]; testString[0] = "adam"; testString[1] = "alexandria"; testString[2] = "apartment"; testString[3] = "apple"; testString[4] = "aaaaaaaaaaaa"; testString[5] = "AAAAAAAAAAAA"; testString[6] = "!@#$%^^&*!@#"; testString[7] = "\u3053\u306e\u30b9\u30e9\u30a4\u30c9\u30da\u30fc\u30b8\u306b\u79fb\u52d5"; testString[8] = "\u3042 \u3044 \u3046 \u3048 \u304a \u304b \u304d \u304f \u3051 \u3053 \u3055 \u3057 \u3059 \u305b \u305d \u304c \u304e \u3050 \u3052 \u3054 \u3071 \u3074 \u3077 \u307a \u307d"; testString[9] = "wwwwwwwwwwwwwwwwwerwerwerwerweiurhowehriouwheorwemrowiehrmowiehhowieuhwomieurhmwieuhmrwuhemroiwuhemrowiuehrmoiwuehrmowieuhrmoiwuehromiwuehmriuwebifbvwdyfovwdy"; testString[10] = "a"; testString[11] = "9834658937469587639487569873645"; for (int i = 0; i < testString.length; i++) { testLong[i] = PrimaryIndexBucketLocatorImpl.convertStringToBuckectingLong(testString[i]); } assertTrue("the string A is supposed to less in value than the string B", testLong[0] < testLong[1]); assertTrue("the string A is supposed to less in value than the string B", testLong[1] < testLong[2]); assertTrue("the string A is supposed to less in value than the string B", testLong[2] < testLong[3]); }
@Test public void testConvertGreekStringToLong() { logger.debug("convert Greek string to long test"); String[] testString = new String[10]; Long[] testLong = new Long[10]; testString[0] = "Ξ ξ"; testString[1] = "Οappleο"; testString[2] = "Π π"; testString[3] = "Σiuyhσ/ς"; testString[4] = "Φaaaaaφ"; testString[5] = "Ψ ψ"; testString[6] = "Λ λ"; for (int i = 0; i < testString.length; i++) { testLong[i] = PrimaryIndexBucketLocatorImpl.convertStringToBuckectingLong(testString[i]); } assertTrue("testString[0] should not be equal to testString[1]", !testLong[0].equals(testLong[1])); assertTrue("testString[1] should not be equal to testString[2]", !testLong[1].equals(testLong[2])); assertTrue("testString[2] should not be equal to testString[3]", !testLong[2].equals(testLong[3])); }
@Test public void testConvertArabicStringToLong() { logger.debug("convert Arabic string to long test"); String[] testString = new String[10]; Long[] testLong = new Long[10]; testString[0] = "ص مew"; testString[1] = "ض4ew"; testString[2] = "فfsjdم"; testString[3] = "غ تrfds"; testString[4] = "ظwsd"; testString[5] = "غ"; testString[6] = "فfsjdم"; for (int i = 0; i < testString.length; i++) { testLong[i] = PrimaryIndexBucketLocatorImpl.convertStringToBuckectingLong(testString[i]); } assertTrue("testString[0] is not equal to testString[1] ", !testLong[0].equals(testLong[1])); assertTrue("testString[1] should not be equal to testString[2] ", !testLong[1].equals(testLong[2])); assertTrue("testString[2] should not be equal to testString[3]", !testLong[2].equals(testLong[3])); }
@Test @Ignore public void testConvertStringToBuckectingLong() { System.out.println("convertStringToBuckectingLong"); String stringToBeConverted = ""; Long expResult = null; Long result = PrimaryIndexBucketLocatorImpl.convertStringToBuckectingLong(stringToBeConverted); assertEquals(expResult, result); }