Skip to content

Commit edad468

Browse files
committed
change unit test case
1 parent 2cc6b4f commit edad468

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFUUID.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import static org.junit.Assert.assertNotEquals;
2929
import org.junit.Test;
3030

31+
import java.util.UUID;
3132
import java.util.concurrent.TimeUnit;
3233

3334
/**
@@ -49,13 +50,18 @@ public void testUUID() throws Exception {
4950
@Test
5051
public void testUUIDv7() throws Exception {
5152
UDFUUIDv7 udf = new UDFUUIDv7();
53+
long timestampBefore = System.currentTimeMillis();
5254
String id1 = udf.evaluate(null).toString();
55+
long timestampAfter = System.currentTimeMillis();
56+
UUID v7id1 = UUID.fromString(id1);
57+
assertEquals(7, v7id1.version());;
58+
long v7IdTimeStamp = v7id1.getMostSignificantBits() >>> 16;
59+
assertTrue(v7IdTimeStamp <= timestampAfter && timestampBefore <= v7IdTimeStamp);
5360
String id2 = udf.evaluate(null).toString();
5461
assertNotEquals(id1, id2);
5562
assertEquals(36, id1.length());
5663
assertEquals(36, id2.length());
5764
GenericUDFBridge bridge = new GenericUDFBridge("uuid_v7", false, UDFUUIDv7.class.getName());
5865
assertFalse(FunctionRegistry.isDeterministic(bridge));
5966
}
60-
6167
}

0 commit comments

Comments
 (0)