Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -113,9 +110,9 @@ void testUuidv6CreationWithNullInstant() {
@Test
@DisplayName("Test UUIDUtils for Random UUID")
void testUuidutilsForRandomUuid() {
final java.util.UUID uuid_java = java.util.UUID.randomUUID();
final UUID uuid = UUID.newBuilder().setMsb(uuid_java.getMostSignificantBits())
.setLsb(uuid_java.getLeastSignificantBits()).build();
final var uuidJava = java.util.UUID.randomUUID();
final UUID uuid = UUID.newBuilder().setMsb(uuidJava.getMostSignificantBits())
.setLsb(uuidJava.getLeastSignificantBits()).build();
final Optional<Long> time = UuidUtils.getTime(uuid);
final String uuidString = UuidSerializer.serialize(uuid);

Expand Down Expand Up @@ -222,28 +219,6 @@ void testCreateUprotocolUuidWithDifferentTimeValues() throws InterruptedExceptio

}

@Test
@DisplayName("Test Create both UUIDv6 and v7 to compare performance")
void testCreateBothUuidv6AndV7ToComparePerformance() throws InterruptedException {
final List<UUID> uuidv6List = new ArrayList<>();
final List<UUID> uuidv7List = new ArrayList<>();
final int MAX_COUNT = 10000;

Instant start = Instant.now();
for (int i = 0; i < MAX_COUNT; i++) {
uuidv7List.add(UuidFactory.Factories.UPROTOCOL.factory().create());
}
final Duration v7Diff = Duration.between(start, Instant.now());

start = Instant.now();
for (int i = 0; i < MAX_COUNT; i++) {
uuidv6List.add(UuidFactory.Factories.UUIDV6.factory().create());
}
final Duration v6Diff = Duration.between(start, Instant.now());
System.out.println(
"UUIDv7:[" + v7Diff.toNanos() / MAX_COUNT + "ns]" + " UUIDv6:[" + v6Diff.toNanos() / MAX_COUNT + "ns]");
}

@Test
@DisplayName("Test Create UUIDv7 with the same time to confirm the UUIDs are not the same")
void testCreateUuidv7WithTheSameTimeToConfirmTheUuidsAreNotTheSame() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ void testUuidv7WithInvalidTypes() {
final UUID uuidv6 = UuidFactory.Factories.UUIDV6.factory().create();
final UUID uuid = UUID.newBuilder().setMsb(0L).setLsb(0L).build();

final java.util.UUID uuid_java = java.util.UUID.randomUUID();
final UUID uuidv4 = UUID.newBuilder().setMsb(uuid_java.getMostSignificantBits())
.setLsb(uuid_java.getLeastSignificantBits()).build();
final java.util.UUID uuidJava = java.util.UUID.randomUUID();
final UUID uuidv4 = UUID.newBuilder().setMsb(uuidJava.getMostSignificantBits())
.setLsb(uuidJava.getLeastSignificantBits()).build();

final UuidValidator validator = UuidValidator.Validators.UPROTOCOL.validator();
assertNotNull(validator);
Expand Down