From 0dc8e972c4fc220fa80239a84d678797b9ced4ce Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Sun, 30 Jul 2017 20:11:52 +0200 Subject: [PATCH] Conversion to .toString() and String.valueOf() Add mockHTTPServer() for future HTTP Server Tests --- .../main/java/com/djrapitops/plan/Phrase.java | 80 +++++++++---------- .../plan/command/commands/InspectCommand.java | 6 +- .../plan/command/commands/SearchCommand.java | 7 +- .../commands/manage/ManageHotswapCommand.java | 2 +- .../commands/manage/ManageMoveCommand.java | 2 +- .../plan/data/analysis/ActivityPart.java | 8 +- .../plan/data/cache/PageCacheHandler.java | 1 + .../plan/data/cache/PageLoader.java | 1 + .../plan/utilities/PlaceholderUtils.java | 4 +- .../java/com/djrapitops/plan/data/Tep.java | 13 --- .../djrapitops/plan/data/UserDataTest.java | 4 +- Plan/src/test/java/utils/MockUtils.java | 10 +++ Plan/src/test/java/utils/TestInit.java | 4 +- 13 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 Plan/src/test/java/main/java/com/djrapitops/plan/data/Tep.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Phrase.java b/Plan/src/main/java/com/djrapitops/plan/Phrase.java index 2255867eb..f3c2819b8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Phrase.java +++ b/Plan/src/main/java/com/djrapitops/plan/Phrase.java @@ -22,7 +22,7 @@ public enum Phrase { PREFIX("[Plan] "), ENABLED("Player Analytics Enabled."), DISABLED("Player Analytics Disabled."), - RELOAD_COMPLETE(ChatColor.GREEN + "" + PREFIX + "Reload complete."), + RELOAD_COMPLETE(ChatColor.GREEN.toString() + PREFIX + "Reload complete."), CACHE_SAVE("Saving cached data.."), CACHE_ADD("Added REPLACE0 to Cache."), CACHE_REMOVE("Cleared REPLACE0 from Cache."), @@ -35,7 +35,7 @@ public enum Phrase { DB_ESTABLISHED(REPLACE0 + "-database connection established."), DB_TYPE_DOES_NOT_EXIST("That database type doesn't exist."), DB_FAILURE_DISABLE("Database initialization has failed, disabling Plan."), - NOTIFY_EMPTY_IP(ChatColor.YELLOW + "" + PREFIX + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"), + NOTIFY_EMPTY_IP(ChatColor.YELLOW.toString() + PREFIX + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"), NOTIFY_DISABLED_CHATLISTENER(ChatColor.YELLOW + "Chat listener disabled, nickname info inaccurate."), NOTIFY_DISABLED_GMLISTENER(ChatColor.YELLOW + "Gamemode change listener disabled, Gm times info inaccurate."), NOTIFY_DISABLED_COMMANDLISTENER(ChatColor.YELLOW + "Command usage listener disabled."), @@ -50,9 +50,9 @@ public enum Phrase { VERSION_CHECK_ERROR("Failed to compare versions."), VERSION_FAIL("Failed to get newest version number."), // - USERNAME_NOT_VALID(ChatColor.RED + "" + PREFIX + "This Player doesn't exist."), - USERNAME_NOT_SEEN(ChatColor.RED + "" + PREFIX + "This Player has not played on this server."), - USERNAME_NOT_KNOWN(ChatColor.RED + "" + PREFIX + "Player not found from the database."), + USERNAME_NOT_VALID(ChatColor.RED.toString() + PREFIX + "This Player doesn't exist."), + USERNAME_NOT_SEEN(ChatColor.RED.toString() + PREFIX + "This Player has not played on this server."), + USERNAME_NOT_KNOWN(ChatColor.RED.toString() + PREFIX + "Player not found from the database."), // COLOR_MAIN(ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1))), COLOR_SEC(ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1))), @@ -60,14 +60,14 @@ public enum Phrase { // ARROWS_RIGHT("»"), BALL("•"), - GRABBING_DATA_MESSAGE(COLOR_TER + "" + ARROWS_RIGHT + COLOR_MAIN.color() + " Fetching data to cache.."), + GRABBING_DATA_MESSAGE(COLOR_TER.toString() + ARROWS_RIGHT + COLOR_MAIN.color() + " Fetching data to cache.."), // DEM_UNKNOWN("Not Known"), NOT_IN_TOWN("Not in a town"), NOT_IN_FAC("Not in a faction"), // ANALYSIS("Analysis | "), - COMMAND_TIMEOUT(ChatColor.RED + "" + PREFIX + "REPLACE0 Command timed out! Check '/plan status' & console."), + COMMAND_TIMEOUT(ChatColor.RED.toString() + PREFIX + "REPLACE0 Command timed out! Check '/plan status' & console."), ANALYSIS_START(ANALYSIS + "Beginning analysis of user data.."), ANALYSIS_BOOT_NOTIFY(ANALYSIS + "Boot analysis in 30 seconds.."), ANALYSIS_BOOT(ANALYSIS + "Starting Boot Analysis.."), @@ -89,39 +89,39 @@ public enum Phrase { ERROR_ANALYSIS_FETCH_FAIL("Failed to fetch data for Analysis, Exception occurred."), ERROR_ANALYSIS_DISABLED_TEMPORARILY(ChatColor.YELLOW + "Analysis has been temporarily disabled due to expensive task, use /plan status for info."), // - CMD_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT), - MANAGE_ERROR_INCORRECT_PLUGIN(ChatColor.RED + "" + PREFIX + "Plugin not supported: "), - MANAGE_PROCESS_START(ARROWS_RIGHT + "" + COLOR_SEC.color() + " Processing data.."), - MANAGE_ERROR_PLUGIN_NOT_ENABLED(ChatColor.RED + "" + PREFIX + "Plugin is not enabled: "), - MANAGE_ERROR_INCORRECT_DB(ChatColor.RED + "" + PREFIX + "Incorrect database! (sqlite/mysql accepted): "), - MANAGE_ERROR_SAME_DB(ChatColor.RED + "" + PREFIX + "Can't move to the same database!"), - MANAGE_DATABASE_FAILURE(ChatColor.RED + "" + PREFIX + "One of the databases was not initialized properly."), - MANAGE_DB_CONFIG_REMINDER(ChatColor.YELLOW + "" + PREFIX + "Remember to swap to the new database and reload plugin"), - MANAGE_ERROR_NO_PLAYERS(ChatColor.RED + "" + PREFIX + "Database has no player data!"), - MANAGE_ERROR_BACKUP_FILE_NOT_FOUND(ChatColor.RED + "" + PREFIX + "Backup file doesn't exist!"), - MANAGE_MOVE_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data moved successfully!"), - MANAGE_COPY_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data copied successfully!"), - MANAGE_PROCESS_FAIL(ChatColor.RED + "" + PREFIX + "Something went wrong while processing the data!"), - MANAGE_CLEAR_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data cleared successfully!"), + CMD_FOOTER(COLOR_TER.color().toString() + ARROWS_RIGHT), + MANAGE_ERROR_INCORRECT_PLUGIN(ChatColor.RED.toString() + PREFIX + "Plugin not supported: "), + MANAGE_PROCESS_START(ARROWS_RIGHT.toString() + COLOR_SEC.color() + " Processing data.."), + MANAGE_ERROR_PLUGIN_NOT_ENABLED(ChatColor.RED.toString() + PREFIX + "Plugin is not enabled: "), + MANAGE_ERROR_INCORRECT_DB(ChatColor.RED.toString() + PREFIX + "Incorrect database! (sqlite/mysql accepted): "), + MANAGE_ERROR_SAME_DB(ChatColor.RED.toString() + PREFIX + "Can't move to the same database!"), + MANAGE_DATABASE_FAILURE(ChatColor.RED.toString() + PREFIX + "One of the databases was not initialized properly."), + MANAGE_DB_CONFIG_REMINDER(ChatColor.YELLOW.toString() + PREFIX + "Remember to swap to the new database and reload plugin"), + MANAGE_ERROR_NO_PLAYERS(ChatColor.RED.toString() + PREFIX + "Database has no player data!"), + MANAGE_ERROR_BACKUP_FILE_NOT_FOUND(ChatColor.RED.toString() + PREFIX + "Backup file doesn't exist!"), + MANAGE_MOVE_SUCCESS(ChatColor.GREEN.toString() + PREFIX + "All data moved successfully!"), + MANAGE_COPY_SUCCESS(ChatColor.GREEN.toString() + PREFIX + "All data copied successfully!"), + MANAGE_PROCESS_FAIL(ChatColor.RED.toString() + PREFIX + "Something went wrong while processing the data!"), + MANAGE_CLEAR_SUCCESS(ChatColor.GREEN.toString() + PREFIX + "All data cleared successfully!"), MANAGE_REMOVE_SUCCESS(CMD_FOOTER + " " + COLOR_MAIN.color() + "Data of " + COLOR_TER.color() + "REPLACE0" + COLOR_MAIN.color() + " was removed from Database " + COLOR_TER.color() + "REPLACE1" + COLOR_MAIN.color() + "."), MANAGE_IMPORTING(CMD_FOOTER + " " + COLOR_MAIN.color() + " Importing Data.."), MANAGE_SUCCESS(CMD_FOOTER + " " + COLOR_MAIN.color() + " Success!"), // CMD_BALL(COLOR_SEC.color() + " " + Phrase.BALL.toString() + COLOR_MAIN.color()), - CMD_ANALYZE_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Analysis results"), - CMD_INSPECT_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Inspect results: "), - CMD_INFO_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Info"), - CMD_INFO_VERSION(CMD_BALL + "" + COLOR_MAIN.color() + " Version: " + COLOR_SEC.color() + REPLACE0), - CMD_SEARCH_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Search results for: "), - CMD_SEARCH_SEARCHING(CMD_FOOTER + "" + COLOR_MAIN.color() + " Searching.."), - CMD_HELP_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Help"), - CMD_MANAGE_HELP_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Managment Help"), - CMD_MANAGE_STATUS_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Database status"), - CMD_MANAGE_STATUS_ACTIVE_DB(CMD_BALL + "" + COLOR_MAIN.color() + " Active Database: " + COLOR_SEC.color() + "REPLACE0"), - CMD_MANAGE_STATUS_QUEUE_SAVE(CMD_BALL + "" + COLOR_MAIN.color() + " Save Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_SAVE_LIMIT.getNumber()), - CMD_MANAGE_STATUS_QUEUE_GET(CMD_BALL + "" + COLOR_MAIN.color() + " Get Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_GET_LIMIT.getNumber()), - CMD_MANAGE_STATUS_QUEUE_CLEAR(CMD_BALL + "" + COLOR_MAIN.color() + " Clear Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_CLEAR_LIMIT.getNumber()), - CMD_MANAGE_STATUS_QUEUE_PROCESS(CMD_BALL + "" + COLOR_MAIN.color() + " Process Queue Size: " + COLOR_SEC.color() + "REPLACE0/20000"), + CMD_ANALYZE_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Analysis results"), + CMD_INSPECT_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Inspect results: "), + CMD_INFO_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Info"), + CMD_INFO_VERSION(CMD_BALL.toString() + COLOR_MAIN.color() + " Version: " + COLOR_SEC.color() + REPLACE0), + CMD_SEARCH_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Search results for: "), + CMD_SEARCH_SEARCHING(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Searching.."), + CMD_HELP_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Help"), + CMD_MANAGE_HELP_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Managment Help"), + CMD_MANAGE_STATUS_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Database status"), + CMD_MANAGE_STATUS_ACTIVE_DB(CMD_BALL.toString() + COLOR_MAIN.color() + " Active Database: " + COLOR_SEC.color() + "REPLACE0"), + CMD_MANAGE_STATUS_QUEUE_SAVE(CMD_BALL.toString() + COLOR_MAIN.color() + " Save Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_SAVE_LIMIT.getNumber()), + CMD_MANAGE_STATUS_QUEUE_GET(CMD_BALL.toString() + COLOR_MAIN.color() + " Get Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_GET_LIMIT.getNumber()), + CMD_MANAGE_STATUS_QUEUE_CLEAR(CMD_BALL.toString() + COLOR_MAIN.color() + " Clear Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_CLEAR_LIMIT.getNumber()), + CMD_MANAGE_STATUS_QUEUE_PROCESS(CMD_BALL.toString() + COLOR_MAIN.color() + " Process Queue Size: " + COLOR_SEC.color() + "REPLACE0/20000"), CMD_CLICK_ME("Click Me"), CMD_LINK(COLOR_SEC.color() + " " + BALL + COLOR_MAIN.color() + " Link: " + COLOR_TER.color()), CMD_PASS_PLANLITE("UNUSED"), @@ -168,11 +168,11 @@ public enum Phrase { WARN_OVERWRITE_SOME("Some data in REPLACE0-database will be overwritten!"), WARN_REMOVE("Data in REPLACE0-database will be removed!"), // - COMMAND_SENDER_NOT_PLAYER(ChatColor.RED + "" + PREFIX + "This command can be only used as a player."), - COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED + "" + PREFIX + "Command requires arguments. REPLACE0"), - COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED + "" + PREFIX + "Add -a to confirm execution! REPLACE0"), - COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED + "" + PREFIX + "Command requires one argument."), - COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permission."), + COMMAND_SENDER_NOT_PLAYER(ChatColor.RED.toString() + PREFIX + "This command can be only used as a player."), + COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED.toString() + PREFIX + "Command requires arguments. REPLACE0"), + COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED.toString() + PREFIX + "Add -a to confirm execution! REPLACE0"), + COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED.toString() + PREFIX + "Command requires one argument."), + COMMAND_NO_PERMISSION(ChatColor.RED.toString() + PREFIX + "You do not have the required permission."), ERROR_TOO_SMALL_QUEUE("Queue size is too small! (REPLACE0), change the setting to a higher number! (Currently REPLACE1)"); private String text; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 627af3b88..9a16ff96a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -89,7 +89,7 @@ public class InspectCommand extends SubCommand { if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), Phrase.USERNAME_NOT_KNOWN.toString(), sender)) { return; } - sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + ""); + sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE.toString()); if (CommandUtils.isPlayer(sender) && plugin.getUiServer().isAuthRequired()) { boolean senderHasWebUser = plugin.getDB().getSecurityTable().userExists(sender.getName()); if (!senderHasWebUser) { @@ -140,7 +140,7 @@ public class InspectCommand extends SubCommand { } else { // Link String url = HtmlUtils.getInspectUrlWithProtocol(playerName); - String message = Phrase.CMD_LINK + ""; + String message = Phrase.CMD_LINK.toString(); boolean console = !CommandUtils.isPlayer(sender); if (console) { sender.sendMessage(message + url); @@ -150,6 +150,6 @@ public class InspectCommand extends SubCommand { } } - sender.sendMessage(Phrase.CMD_FOOTER + ""); + sender.sendMessage(Phrase.CMD_FOOTER.toString()); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index c1329dc29..9b10e0b76 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -31,7 +31,7 @@ public class SearchCommand extends SubCommand { * @param plugin Current instance of Plan */ public SearchCommand(Plan plugin) { - super("search", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.SEARCH.getPermission(), Phrase.CMD_USG_SEARCH + "", Phrase.ARG_SEARCH + ""); + super("search", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.SEARCH.getPermission(), Phrase.CMD_USG_SEARCH.toString(), Phrase.ARG_SEARCH.toString()); this.plugin = plugin; setHelp(plugin); } @@ -57,7 +57,7 @@ public class SearchCommand extends SubCommand { if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) { return true; } - sender.sendMessage(Phrase.CMD_SEARCH_SEARCHING + ""); + sender.sendMessage(Phrase.CMD_SEARCH_SEARCHING.toString()); runSearchTask(args, sender); return true; @@ -74,8 +74,9 @@ public class SearchCommand extends SubCommand { if (names.isEmpty()) { sender.sendMessage(Phrase.CMD_NO_RESULTS.parse(Arrays.toString(args))); } else { - sender.sendMessage(Phrase.CMD_MATCH + "" + FormattingUtils.collectionToStringNoBrackets(names)); + sender.sendMessage(Phrase.CMD_MATCH.toString() + FormattingUtils.collectionToStringNoBrackets(names)); } + sender.sendMessage(Phrase.CMD_FOOTER.toString()); } finally { this.cancel(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index 30aff5272..a08f59a83 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -64,7 +64,7 @@ public class ManageHotswapCommand extends SubCommand { return true; } - if (Check.isTrue(dbName.equals(plugin.getDB().getConfigName()), Phrase.MANAGE_ERROR_SAME_DB + "", sender)) { + if (Check.isTrue(dbName.equals(plugin.getDB().getConfigName()), Phrase.MANAGE_ERROR_SAME_DB.toString(), sender)) { return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index ffec8a003..a0c10ff11 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -98,7 +98,7 @@ public class ManageMoveCommand extends SubCommand { sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse()); if (ManageUtils.clearAndCopy(toDatabase, fromDatabase, uuids)) { - sender.sendMessage(Phrase.MANAGE_MOVE_SUCCESS + ""); + sender.sendMessage(Phrase.MANAGE_MOVE_SUCCESS.toString()); boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName()); Check.isTrue(!movedToCurrentDatabase, Phrase.MANAGE_DB_CONFIG_REMINDER.toString(), sender); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/analysis/ActivityPart.java b/Plan/src/main/java/com/djrapitops/plan/data/analysis/ActivityPart.java index 624c333f6..20e37acf2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/analysis/ActivityPart.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/analysis/ActivityPart.java @@ -89,10 +89,10 @@ public class ActivityPart extends RawData { private void activityPiechart() { int[] counts = new int[]{active.size(), inactive.size(), joinedOnce.size(), bans.size()}; - final String colAct = Settings.HCOLOR_ACTP_ACT + ""; - final String colIna = Settings.HCOLOR_ACTP_INA + ""; - final String colJoi = Settings.HCOLOR_ACTP_JON + ""; - final String colBan = Settings.HCOLOR_ACTP_BAN + ""; + final String colAct = Settings.HCOLOR_ACTP_ACT.toString(); + final String colIna = Settings.HCOLOR_ACTP_INA.toString(); + final String colJoi = Settings.HCOLOR_ACTP_JON.toString(); + final String colBan = Settings.HCOLOR_ACTP_BAN.toString(); addValue("%activecol%", colAct); addValue("%inactivecol%", colIna); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/cache/PageCacheHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/cache/PageCacheHandler.java index c03f7f92c..a84dccae2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/cache/PageCacheHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/cache/PageCacheHandler.java @@ -14,6 +14,7 @@ import main.java.com.djrapitops.plan.ui.webserver.response.Response; * This cache uses the Google Guava {@link Cache}. * * @author Fuzzlemann + * @since 3.6.0 */ public class PageCacheHandler { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/cache/PageLoader.java b/Plan/src/main/java/com/djrapitops/plan/data/cache/PageLoader.java index 323110a86..947019430 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/cache/PageLoader.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/cache/PageLoader.java @@ -6,6 +6,7 @@ import main.java.com.djrapitops.plan.ui.webserver.response.Response; * This interface is used for providing the method to load the page. * * @author Fuzzlemann + * @since 3.6.0 */ public interface PageLoader { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java index ef3268468..57e1c8273 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java @@ -69,9 +69,9 @@ public class PlaceholderUtils { HashMap replaceMap = new HashMap<>(); boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue(); UUID uuid = data.getUuid(); - replaceMap.put("%uuid%", (showIPandUUID ? "" + uuid : Html.HIDDEN.parse())); + replaceMap.put("%uuid%", (showIPandUUID ? String.valueOf(uuid) : Html.HIDDEN.parse())); replaceMap.put("%lastseen%", FormatUtils.formatTimeStampYear(data.getLastPlayed())); - replaceMap.put("%logintimes%", "" + data.getLoginTimes()); + replaceMap.put("%logintimes%", String.valueOf(data.getLoginTimes())); replaceMap.put("%geoloc%", data.getGeolocation()); long now = MiscUtils.getTime(); boolean isActive = AnalysisUtils.isActive(now, data.getLastPlayed(), data.getPlayTime(), data.getLoginTimes()); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/data/Tep.java b/Plan/src/test/java/main/java/com/djrapitops/plan/data/Tep.java deleted file mode 100644 index 1dbbe35da..000000000 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/data/Tep.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package test.java.main.java.com.djrapitops.plan.data; - -/** - * @author ristolah - */ -public class Tep { - -} diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java index 1b192d1c8..132827ee0 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java @@ -149,7 +149,7 @@ public class UserDataTest { public void testSetGMTime() { test.setGMTime("SURVIVAL", 1L); final Long result = test.getGmTimes().get("SURVIVAL"); - assertTrue("" + result, result == 1L); + assertTrue(String.valueOf(result), result == 1L); } /** @@ -161,7 +161,7 @@ public class UserDataTest { String gm = "SURVIVAL"; test.setGMTime(gm, 1L); final Long result = test.getGmTimes().get(gm); - assertTrue("" + result, result == 1L); + assertTrue(String.valueOf(result), result == 1L); } /** diff --git a/Plan/src/test/java/utils/MockUtils.java b/Plan/src/test/java/utils/MockUtils.java index b2f792f4e..f5e836968 100644 --- a/Plan/src/test/java/utils/MockUtils.java +++ b/Plan/src/test/java/utils/MockUtils.java @@ -2,6 +2,7 @@ package test.java.utils; import com.djrapitops.plugin.utilities.player.Fetch; import com.djrapitops.plugin.utilities.player.IPlayer; +import com.sun.net.httpserver.HttpServer; import main.java.com.djrapitops.plan.data.KillData; import main.java.com.djrapitops.plan.data.SessionData; import main.java.com.djrapitops.plan.data.UserData; @@ -15,6 +16,8 @@ import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.UnknownHostException; import java.util.UUID; import static org.powermock.api.mockito.PowerMockito.when; @@ -139,4 +142,11 @@ public class MockUtils { public static CommandSender mockConsoleSender() { return PowerMockito.mock(CommandSender.class); } + + public static HttpServer mockHTTPServer() throws UnknownHostException { + HttpServer httpServer = PowerMockito.mock(HttpServer.class); + when(httpServer.getAddress()).thenReturn(InetSocketAddress.createUnresolved("127.0.0.1", 80)); + when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received")); + return httpServer; + } } diff --git a/Plan/src/test/java/utils/TestInit.java b/Plan/src/test/java/utils/TestInit.java index 09bdeeabb..b4ea433f4 100644 --- a/Plan/src/test/java/utils/TestInit.java +++ b/Plan/src/test/java/utils/TestInit.java @@ -105,9 +105,9 @@ public class TestInit { } private YamlConfiguration mockConfig() throws IOException, InvalidConfigurationException { - File configfile = new File(getClass().getResource("/config.yml").getPath()); + File configFile = new File(getClass().getResource("/config.yml").getPath()); YamlConfiguration configuration = new YamlConfiguration(); - configuration.load(configfile.getAbsolutePath()); + configuration.load(configFile.getAbsolutePath()); return configuration; }