mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2025-01-10 09:47:59 +01:00
Update to BentoBox 2.0.0 API
This commit is contained in:
parent
1a4077be8c
commit
77884f0a11
@ -356,7 +356,7 @@ public class LevelsManager {
|
|||||||
public int getRank(@NonNull World world, UUID uuid) {
|
public int getRank(@NonNull World world, UUID uuid) {
|
||||||
createAndCleanRankings(world);
|
createAndCleanRankings(world);
|
||||||
Stream<Entry<UUID, Long>> stream = topTenLists.get(world).getTopTen().entrySet().stream()
|
Stream<Entry<UUID, Long>> stream = topTenLists.get(world).getTopTen().entrySet().stream()
|
||||||
.filter(e -> addon.getIslands().isOwner(world, e.getKey())).filter(l -> l.getValue() > 0)
|
.filter(e -> addon.getIslands().hasIsland(world, e.getKey())).filter(l -> l.getValue() > 0)
|
||||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
|
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
|
||||||
return (int) (stream.takeWhile(x -> !x.getKey().equals(uuid)).map(Map.Entry::getKey).count() + 1);
|
return (int) (stream.takeWhile(x -> !x.getKey().equals(uuid)).map(Map.Entry::getKey).count() + 1);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -70,65 +70,63 @@ import world.bentobox.level.objects.TopTenData;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Bukkit.class, BentoBox.class, DatabaseSetup.class, PanelBuilder.class})
|
@PrepareForTest({ Bukkit.class, BentoBox.class, DatabaseSetup.class, PanelBuilder.class })
|
||||||
public class LevelsManagerTest {
|
public class LevelsManagerTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private static AbstractDatabaseHandler<Object> handler;
|
private static AbstractDatabaseHandler<Object> handler;
|
||||||
@Mock
|
@Mock
|
||||||
Level addon;
|
Level addon;
|
||||||
@Mock
|
@Mock
|
||||||
private BentoBox plugin;
|
private BentoBox plugin;
|
||||||
@Mock
|
@Mock
|
||||||
private Settings pluginSettings;
|
private Settings pluginSettings;
|
||||||
|
|
||||||
|
// Class under test
|
||||||
|
private LevelsManager lm;
|
||||||
|
@Mock
|
||||||
|
private Island island;
|
||||||
|
@Mock
|
||||||
|
private Pipeliner pipeliner;
|
||||||
|
private CompletableFuture<Results> cf;
|
||||||
|
private UUID uuid;
|
||||||
|
@Mock
|
||||||
|
private World world;
|
||||||
|
@Mock
|
||||||
|
private Player player;
|
||||||
|
@Mock
|
||||||
|
private ConfigSettings settings;
|
||||||
|
@Mock
|
||||||
|
private User user;
|
||||||
|
@Mock
|
||||||
|
private PlayersManager pm;
|
||||||
|
@Mock
|
||||||
|
private Inventory inv;
|
||||||
|
@Mock
|
||||||
|
private IslandWorldManager iwm;
|
||||||
|
@Mock
|
||||||
|
private PluginManager pim;
|
||||||
|
@Mock
|
||||||
|
private IslandLevels levelsData;
|
||||||
|
@Mock
|
||||||
|
private IslandsManager im;
|
||||||
|
@Mock
|
||||||
|
private BukkitScheduler scheduler;
|
||||||
|
|
||||||
// Class under test
|
@SuppressWarnings("unchecked")
|
||||||
private LevelsManager lm;
|
@BeforeClass
|
||||||
@Mock
|
public static void beforeClass() {
|
||||||
private Island island;
|
// This has to be done beforeClass otherwise the tests will interfere with each
|
||||||
@Mock
|
// other
|
||||||
private Pipeliner pipeliner;
|
handler = mock(AbstractDatabaseHandler.class);
|
||||||
private CompletableFuture<Results> cf;
|
// Database
|
||||||
private UUID uuid;
|
PowerMockito.mockStatic(DatabaseSetup.class);
|
||||||
@Mock
|
DatabaseSetup dbSetup = mock(DatabaseSetup.class);
|
||||||
private World world;
|
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
|
||||||
@Mock
|
when(dbSetup.getHandler(any())).thenReturn(handler);
|
||||||
private Player player;
|
}
|
||||||
@Mock
|
|
||||||
private ConfigSettings settings;
|
|
||||||
@Mock
|
|
||||||
private User user;
|
|
||||||
@Mock
|
|
||||||
private PlayersManager pm;
|
|
||||||
@Mock
|
|
||||||
private Inventory inv;
|
|
||||||
@Mock
|
|
||||||
private IslandWorldManager iwm;
|
|
||||||
@Mock
|
|
||||||
private PluginManager pim;
|
|
||||||
@Mock
|
|
||||||
private IslandLevels levelsData;
|
|
||||||
@Mock
|
|
||||||
private IslandsManager im;
|
|
||||||
@Mock
|
|
||||||
private BukkitScheduler scheduler;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@BeforeClass
|
|
||||||
public static void beforeClass() {
|
|
||||||
// This has to be done beforeClass otherwise the tests will interfere with each other
|
|
||||||
handler = mock(AbstractDatabaseHandler.class);
|
|
||||||
// Database
|
|
||||||
PowerMockito.mockStatic(DatabaseSetup.class);
|
|
||||||
DatabaseSetup dbSetup = mock(DatabaseSetup.class);
|
|
||||||
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
|
|
||||||
when(dbSetup.getHandler(any())).thenReturn(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -164,8 +162,7 @@ public class LevelsManagerTest {
|
|||||||
when(island.getWorld()).thenReturn(world);
|
when(island.getWorld()).thenReturn(world);
|
||||||
when(island.getUniqueId()).thenReturn(UUID.randomUUID().toString());
|
when(island.getUniqueId()).thenReturn(UUID.randomUUID().toString());
|
||||||
// Default to uuid's being island owners
|
// Default to uuid's being island owners
|
||||||
when(im.isOwner(eq(world), any())).thenReturn(true);
|
when(im.hasIsland(eq(world), any(UUID.class))).thenReturn(true);
|
||||||
when(im.getOwner(any(), any(UUID.class))).thenAnswer(in -> in.getArgument(1, UUID.class));
|
|
||||||
when(im.getIsland(world, uuid)).thenReturn(island);
|
when(im.getIsland(world, uuid)).thenReturn(island);
|
||||||
when(im.getIslandById(anyString())).thenReturn(Optional.of(island));
|
when(im.getIslandById(anyString())).thenReturn(Optional.of(island));
|
||||||
|
|
||||||
@ -235,220 +232,229 @@ public class LevelsManagerTest {
|
|||||||
lm.migrate();
|
lm.migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
deleteAll(new File("database"));
|
deleteAll(new File("database"));
|
||||||
User.clearUsers();
|
User.clearUsers();
|
||||||
Mockito.framework().clearInlineMocks();
|
Mockito.framework().clearInlineMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteAll(File file) throws IOException {
|
private static void deleteAll(File file) throws IOException {
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
Files.walk(file.toPath())
|
Files.walk(file.toPath()).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
|
||||||
.sorted(Comparator.reverseOrder())
|
}
|
||||||
.map(Path::toFile)
|
}
|
||||||
.forEach(File::delete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#calculateLevel(UUID, world.bentobox.bentobox.database.objects.Island)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#calculateLevel(UUID, world.bentobox.bentobox.database.objects.Island)}.
|
||||||
@Test
|
*/
|
||||||
public void testCalculateLevel() {
|
@Test
|
||||||
Results results = new Results();
|
public void testCalculateLevel() {
|
||||||
results.setLevel(10000);
|
Results results = new Results();
|
||||||
results.setInitialLevel(3);
|
results.setLevel(10000);
|
||||||
lm.calculateLevel(uuid, island);
|
results.setInitialLevel(3);
|
||||||
// Complete the pipelined completable future
|
lm.calculateLevel(uuid, island);
|
||||||
cf.complete(results);
|
// Complete the pipelined completable future
|
||||||
|
cf.complete(results);
|
||||||
|
|
||||||
assertEquals(10000L, lm.getLevelsData(island).getLevel());
|
assertEquals(10000L, lm.getLevelsData(island).getLevel());
|
||||||
//Map<UUID, Long> tt = lm.getTopTen(world, 10);
|
// Map<UUID, Long> tt = lm.getTopTen(world, 10);
|
||||||
//assertEquals(1, tt.size());
|
// assertEquals(1, tt.size());
|
||||||
//assertTrue(tt.get(uuid) == 10000);
|
// assertTrue(tt.get(uuid) == 10000);
|
||||||
assertEquals(10000L, lm.getIslandMaxLevel(world, uuid));
|
assertEquals(10000L, lm.getIslandMaxLevel(world, uuid));
|
||||||
|
|
||||||
results.setLevel(5000);
|
results.setLevel(5000);
|
||||||
lm.calculateLevel(uuid, island);
|
lm.calculateLevel(uuid, island);
|
||||||
// Complete the pipelined completable future
|
// Complete the pipelined completable future
|
||||||
cf.complete(results);
|
cf.complete(results);
|
||||||
assertEquals(5000L, lm.getLevelsData(island).getLevel());
|
assertEquals(5000L, lm.getLevelsData(island).getLevel());
|
||||||
// Still should be 10000
|
// Still should be 10000
|
||||||
assertEquals(10000L, lm.getIslandMaxLevel(world, uuid));
|
assertEquals(10000L, lm.getIslandMaxLevel(world, uuid));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getInitialLevel(world.bentobox.bentobox.database.objects.Island)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getInitialLevel(world.bentobox.bentobox.database.objects.Island)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetInitialLevel() {
|
@Test
|
||||||
assertEquals(0,lm.getInitialLevel(island));
|
public void testGetInitialLevel() {
|
||||||
}
|
assertEquals(0, lm.getInitialLevel(island));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getIslandLevel(org.bukkit.World, java.util.UUID)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getIslandLevel(org.bukkit.World, java.util.UUID)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetIslandLevel() {
|
@Test
|
||||||
assertEquals(-5, lm.getIslandLevel(world, uuid));
|
public void testGetIslandLevel() {
|
||||||
}
|
assertEquals(-5, lm.getIslandLevel(world, uuid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getPointsToNextString(org.bukkit.World, java.util.UUID)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getPointsToNextString(org.bukkit.World, java.util.UUID)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetPointsToNextString() {
|
@Test
|
||||||
// No island player
|
public void testGetPointsToNextString() {
|
||||||
assertEquals("", lm.getPointsToNextString(world, UUID.randomUUID()));
|
// No island player
|
||||||
// Player has island
|
assertEquals("", lm.getPointsToNextString(world, UUID.randomUUID()));
|
||||||
assertEquals("0", lm.getPointsToNextString(world, uuid));
|
// Player has island
|
||||||
}
|
assertEquals("0", lm.getPointsToNextString(world, uuid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getIslandLevelString(org.bukkit.World, java.util.UUID)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getIslandLevelString(org.bukkit.World, java.util.UUID)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetIslandLevelString() {
|
@Test
|
||||||
assertEquals("-5", lm.getIslandLevelString(world, uuid));
|
public void testGetIslandLevelString() {
|
||||||
}
|
assertEquals("-5", lm.getIslandLevelString(world, uuid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getLevelsData(java.util.UUID)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getLevelsData(java.util.UUID)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetLevelsData() {
|
@Test
|
||||||
assertEquals(levelsData, lm.getLevelsData(island));
|
public void testGetLevelsData() {
|
||||||
|
assertEquals(levelsData, lm.getLevelsData(island));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#formatLevel(long)}.
|
* Test method for {@link world.bentobox.level.LevelsManager#formatLevel(long)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFormatLevel() {
|
public void testFormatLevel() {
|
||||||
assertEquals("123456789", lm.formatLevel(123456789L));
|
assertEquals("123456789", lm.formatLevel(123456789L));
|
||||||
when(settings.isShorthand()).thenReturn(true);
|
when(settings.isShorthand()).thenReturn(true);
|
||||||
assertEquals("123.5M", lm.formatLevel(123456789L));
|
assertEquals("123.5M", lm.formatLevel(123456789L));
|
||||||
assertEquals("1.2k", lm.formatLevel(1234L));
|
assertEquals("1.2k", lm.formatLevel(1234L));
|
||||||
assertEquals("123.5G", lm.formatLevel(123456789352L));
|
assertEquals("123.5G", lm.formatLevel(123456789352L));
|
||||||
assertEquals("1.2T", lm.formatLevel(1234567893524L));
|
assertEquals("1.2T", lm.formatLevel(1234567893524L));
|
||||||
assertEquals("12345.7T", lm.formatLevel(12345678345345349L));
|
assertEquals("12345.7T", lm.formatLevel(12345678345345349L));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getTopTen(org.bukkit.World, int)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getTopTen(org.bukkit.World, int)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetTopTenEmpty() {
|
@Test
|
||||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
public void testGetTopTenEmpty() {
|
||||||
assertTrue(tt.isEmpty());
|
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||||
}
|
assertTrue(tt.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getTopTen(org.bukkit.World, int)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#getTopTen(org.bukkit.World, int)}.
|
||||||
@Test
|
*/
|
||||||
public void testGetTopTen() {
|
@Test
|
||||||
testLoadTopTens();
|
public void testGetTopTen() {
|
||||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
testLoadTopTens();
|
||||||
assertFalse(tt.isEmpty());
|
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||||
assertEquals(1, tt.size());
|
assertFalse(tt.isEmpty());
|
||||||
assertEquals(1, lm.getTopTen(world, 1).size());
|
assertEquals(1, tt.size());
|
||||||
}
|
assertEquals(1, lm.getTopTen(world, 1).size());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getTopTen(org.bukkit.World, int)}.
|
* Test method for {@link world.bentobox.level.LevelsManager#getTopTen(org.bukkit.World, int)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetTopTenNoOwners() {
|
public void testGetTopTenNoOwners() {
|
||||||
when(im.isOwner(eq(world), any())).thenReturn(false);
|
when(im.hasIsland(eq(world), any(UUID.class))).thenReturn(false);
|
||||||
testLoadTopTens();
|
testLoadTopTens();
|
||||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||||
assertTrue(tt.isEmpty());
|
assertTrue(tt.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#hasTopTenPerm(org.bukkit.World, java.util.UUID)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#hasTopTenPerm(org.bukkit.World, java.util.UUID)}.
|
||||||
@Test
|
*/
|
||||||
public void testHasTopTenPerm() {
|
@Test
|
||||||
assertTrue(lm.hasTopTenPerm(world, uuid));
|
public void testHasTopTenPerm() {
|
||||||
}
|
assertTrue(lm.hasTopTenPerm(world, uuid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#loadTopTens()}.
|
* Test method for {@link world.bentobox.level.LevelsManager#loadTopTens()}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadTopTens() {
|
public void testLoadTopTens() {
|
||||||
ArgumentCaptor<Runnable> task = ArgumentCaptor.forClass(Runnable.class);
|
ArgumentCaptor<Runnable> task = ArgumentCaptor.forClass(Runnable.class);
|
||||||
lm.loadTopTens();
|
lm.loadTopTens();
|
||||||
PowerMockito.verifyStatic(Bukkit.class); // 1
|
PowerMockito.verifyStatic(Bukkit.class); // 1
|
||||||
Bukkit.getScheduler();
|
Bukkit.getScheduler();
|
||||||
verify(scheduler).runTaskAsynchronously(eq(plugin), task.capture());
|
verify(scheduler).runTaskAsynchronously(eq(plugin), task.capture());
|
||||||
task.getValue().run();
|
task.getValue().run();
|
||||||
verify(addon).log("Generating rankings");
|
verify(addon).log("Generating rankings");
|
||||||
verify(addon).log("Generated rankings for bskyblock-world");
|
verify(addon).log("Generated rankings for bskyblock-world");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#removeEntry(org.bukkit.World, java.util.UUID)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#removeEntry(org.bukkit.World, java.util.UUID)}.
|
||||||
@Test
|
*/
|
||||||
public void testRemoveEntry() {
|
@Test
|
||||||
testLoadTopTens();
|
public void testRemoveEntry() {
|
||||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
testLoadTopTens();
|
||||||
assertTrue(tt.containsKey(uuid));
|
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||||
lm.removeEntry(world, uuid);
|
assertTrue(tt.containsKey(uuid));
|
||||||
tt = lm.getTopTen(world, Level.TEN);
|
lm.removeEntry(world, uuid);
|
||||||
assertFalse(tt.containsKey(uuid));
|
tt = lm.getTopTen(world, Level.TEN);
|
||||||
}
|
assertFalse(tt.containsKey(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#setInitialIslandLevel(world.bentobox.bentobox.database.objects.Island, long)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#setInitialIslandLevel(world.bentobox.bentobox.database.objects.Island, long)}.
|
||||||
@Test
|
*/
|
||||||
public void testSetInitialIslandLevel() {
|
@Test
|
||||||
lm.setInitialIslandLevel(island, Level.TEN);
|
public void testSetInitialIslandLevel() {
|
||||||
assertEquals(Level.TEN, lm.getInitialLevel(island));
|
lm.setInitialIslandLevel(island, Level.TEN);
|
||||||
}
|
assertEquals(Level.TEN, lm.getInitialLevel(island));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#setIslandLevel(org.bukkit.World, java.util.UUID, long)}.
|
* Test method for
|
||||||
*/
|
* {@link world.bentobox.level.LevelsManager#setIslandLevel(org.bukkit.World, java.util.UUID, long)}.
|
||||||
@Test
|
*/
|
||||||
public void testSetIslandLevel() {
|
@Test
|
||||||
lm.setIslandLevel(world, uuid, 1234);
|
public void testSetIslandLevel() {
|
||||||
assertEquals(1234, lm.getIslandLevel(world, uuid));
|
lm.setIslandLevel(world, uuid, 1234);
|
||||||
|
assertEquals(1234, lm.getIslandLevel(world, uuid));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Test method for
|
||||||
* Test method for {@link world.bentobox.level.LevelsManager#getRank(World, UUID)}
|
* {@link world.bentobox.level.LevelsManager#getRank(World, UUID)}
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetRank() {
|
public void testGetRank() {
|
||||||
lm.createAndCleanRankings(world);
|
lm.createAndCleanRankings(world);
|
||||||
Map<World, TopTenData> ttl = lm.getTopTenLists();
|
Map<World, TopTenData> ttl = lm.getTopTenLists();
|
||||||
Map<UUID, Long> tt = ttl.get(world).getTopTen();
|
Map<UUID, Long> tt = ttl.get(world).getTopTen();
|
||||||
for (long i = 100; i < 150; i++) {
|
for (long i = 100; i < 150; i++) {
|
||||||
tt.put(UUID.randomUUID(), i);
|
tt.put(UUID.randomUUID(), i);
|
||||||
}
|
}
|
||||||
// Put player as lowest rank
|
// Put player as lowest rank
|
||||||
tt.put(uuid, 10L);
|
tt.put(uuid, 10L);
|
||||||
assertEquals(51, lm.getRank(world, uuid));
|
assertEquals(51, lm.getRank(world, uuid));
|
||||||
// Put player as highest rank
|
// Put player as highest rank
|
||||||
tt.put(uuid, 1000L);
|
tt.put(uuid, 1000L);
|
||||||
assertEquals(1, lm.getRank(world, uuid));
|
assertEquals(1, lm.getRank(world, uuid));
|
||||||
// Unknown UUID - lowest rank + 1
|
// Unknown UUID - lowest rank + 1
|
||||||
assertEquals(52, lm.getRank(world, UUID.randomUUID()));
|
assertEquals(52, lm.getRank(world, UUID.randomUUID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user