From a548ae6cf62d63960c6804402858621fc0fdcf9c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 29 Jan 2019 11:05:36 +0200 Subject: [PATCH] Removed WorldTable#saveWorlds --- .../plan/db/sql/tables/WorldTable.java | 4 --- .../com/djrapitops/plan/db/CommonDBTest.java | 34 ++++++++++--------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java index d8ee5329d..feae845eb 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/WorldTable.java @@ -97,10 +97,6 @@ public class WorldTable extends Table { }); } - public void saveWorlds(Collection worlds) { - saveWorlds(worlds, getServerUUID()); - } - /** * Used to save a list of world names. *

diff --git a/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java b/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java index 676d98f2b..3ce56ce9b 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java @@ -83,7 +83,7 @@ public abstract class CommonDBTest { public static SQLDB db; public static PlanSystem system; - public final List worlds = Arrays.asList("TestWorld", "TestWorld2"); + public final String[] worlds = new String[]{"TestWorld", "TestWorld2"}; public final UUID playerUUID = TestConstants.PLAYER_ONE_UUID; public final UUID player2UUID = TestConstants.PLAYER_TWO_UUID; @@ -297,19 +297,28 @@ public abstract class CommonDBTest { } @Test - public void testWorldTable() throws DBInitException { - WorldTable worldTable = db.getWorldTable(); - List worlds = Arrays.asList("Test", "Test2", "Test3"); - worldTable.saveWorlds(worlds); + public void worldNamesAreStored() throws DBInitException { + String[] expected = {"Test", "Test2", "Test3"}; + saveWorlds(expected); commitTest(); - List saved = worldTable.getWorlds(serverUUID); - assertEquals(new HashSet<>(worlds), new HashSet<>(saved)); + Collection result = db.query(LargeFetchQueries.fetchAllWorldNames()).getOrDefault(serverUUID, new HashSet<>()); + assertEquals(Arrays.asList(expected), result); + } + + private void saveWorld(String worldName) { + db.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName)); + } + + private void saveWorlds(String... worldNames) { + for (String worldName : worldNames) { + saveWorld(worldName); + } } private void saveTwoWorlds() { - db.getWorldTable().saveWorlds(worlds); + saveWorlds(worlds); } private WorldTimes createWorldTimes() { @@ -321,7 +330,7 @@ public abstract class CommonDBTest { gm.put(gms[2], 3000L); gm.put(gms[3], 4000L); - String worldName = worlds.get(0); + String worldName = worlds[0]; times.put(worldName, new GMTimes(gm)); db.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName)); @@ -794,13 +803,6 @@ public abstract class CommonDBTest { assertTrue(db.check().isPlayerRegisteredOnThisServer(playerUUID)); } - @Test - public void testWorldTableGetWorldNamesNoException() throws NoSuchAlgorithmException { - saveAllData(); - Set worldNames = db.getWorldTable().getWorldNames(serverUUID); - assertEquals(new HashSet<>(worlds), worldNames); - } - @Test public void testGetNetworkGeolocations() { GeoInfoTable geoInfoTable = db.getGeoInfoTable();