Skip to content

Commit 96e5ec6

Browse files
committed
Isolate UUID lookup regression test
1 parent 5a7bf6a commit 96e5ec6

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎AdvancedCore/src/main/java/com/bencodez/advancedcore/api/player/UuidLookup.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818

1919
public class UuidLookup {
2020

21-
private static final UuidLookup instance = new UuidLookup();
21+
private static final UuidLookup instance = new UuidLookup(AdvancedCorePlugin.getInstance());
2222

2323
public static UuidLookup getInstance() {
2424
return instance;
2525
}
2626

27-
private final AdvancedCorePlugin plugin = AdvancedCorePlugin.getInstance();
27+
private final AdvancedCorePlugin plugin;
2828

2929
// Fast local caches
3030
private final ConcurrentHashMap<String, String> uuidToName = new ConcurrentHashMap<>();
3131
private final ConcurrentHashMap<String, String> nameToUuid = new ConcurrentHashMap<>();
3232

33-
private UuidLookup() {
33+
private UuidLookup(AdvancedCorePlugin plugin) {
34+
this.plugin = plugin;
3435
// Cache is owned here.
3536
}
3637

‎AdvancedCore/src/test/java/com/bencodez/advancedcore/tests/user/SharedCacheCleanupPrimaryThreadTest.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ void primaryThreadIdentityLookupUsesOnlyKnownOnlineOfflineOrCachedIdentity() thr
6161
AdvancedCoreConfigOptions options = mock(AdvancedCoreConfigOptions.class);
6262
when(plugin.getOptions()).thenReturn(options);
6363
when(options.isOnlineMode()).thenReturn(true);
64-
try (var plugins = mockStatic(AdvancedCorePlugin.class); var bukkit = mockStatic(Bukkit.class)) {
65-
plugins.when(AdvancedCorePlugin::getInstance).thenReturn(plugin);
66-
Constructor<UuidLookup> constructor = UuidLookup.class.getDeclaredConstructor();
64+
try (var bukkit = mockStatic(Bukkit.class)) {
65+
Constructor<UuidLookup> constructor = UuidLookup.class.getDeclaredConstructor(AdvancedCorePlugin.class);
6766
constructor.setAccessible(true);
68-
UuidLookup lookup = constructor.newInstance();
67+
UuidLookup lookup = constructor.newInstance(plugin);
6968
String unknown = "Unknown" + UUID.randomUUID().toString().replace("-", "");
7069

7170
assertEquals("", lookup.getUUIDWithoutStorage(unknown));

0 commit comments

Comments
 (0)