From 751e0e6cb4ca1ae0ce679047cefe7e4bea924308 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 25 May 2018 10:37:16 +0300 Subject: [PATCH] Removed some unused FormatUtils methods --- .../plan/utilities/FormatUtils.java | 62 -------------- .../plan/utilities/FormatUtilsTest.java | 80 ------------------- 2 files changed, 142 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index d50310f6d..542f62e9d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -2,9 +2,7 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.TimeAmount; -import com.djrapitops.plugin.utilities.Format; import org.apache.commons.lang3.StringUtils; -import org.bukkit.Location; import java.text.DecimalFormat; import java.text.SimpleDateFormat; @@ -37,17 +35,6 @@ public class FormatUtils { return formatMilliseconds(ms); } - /** - * Format the time difference between an end point and a start point. - * - * @param before Epoch ms. - * @param after Epoch ms. - * @return String formatted with the config settings. - */ - public static String formatTimeAmountDifference(long before, long after) { - return formatMilliseconds(Math.abs(after - before)); - } - public static String formatTimeStampISO8601NoClock(long epochMs) { String format = "yyyy-MM-dd"; @@ -117,34 +104,6 @@ public class FormatUtils { return format(epochMs, format); } - /** - * Removes letters from a string leaving only numbers and dots. - * - * @param dataPoint String to remove stuff from. - * @return String with the stuff removed. - */ - public static String removeLetters(String dataPoint) { - return Format.create(dataPoint) - .removeLetters() - .removeWhitespace() - .removeSymbolsButDot() - .toString(); - } - - /** - * Removes numbers from a string leaving only letters. - * - * @param dataPoint String to remove stuff from. - * @return String with the stuff removed. - */ - public static String removeNumbers(String dataPoint) { - return Format.create(dataPoint) - .removeNumbers() - .removeWhitespace() - .removeDot() - .toString(); - } - // Formats long in milliseconds into d:h:m:s string private static String formatMilliseconds(long ms) { StringBuilder builder = new StringBuilder(); @@ -234,17 +193,6 @@ public class FormatUtils { return formattedTime; } - /** - * Turns the version string into a integer - * - * @param versionString String - number format 1.1.1 - * @return parsed double - for example 1,11 - * @throws NumberFormatException When wrong format - */ - public static long parseVersionNumber(String versionString) { - return com.djrapitops.plugin.utilities.FormatUtils.parseVersionNumber(versionString); - } - /** * Merges multiple arrays into one. * @@ -255,16 +203,6 @@ public class FormatUtils { return com.djrapitops.plugin.utilities.FormatUtils.mergeArrays(arrays); } - /** - * Formats a Minecraft Location into readable format. - * - * @param loc Location to format - * @return Readable location format. - */ - public static String formatLocation(Location loc) { - return com.djrapitops.plugin.utilities.FormatUtils.formatLocation(loc); - } - /** * Remove extra decimals from the end of the double. * diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java index 87c853d10..f29675377 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java @@ -1,8 +1,6 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plugin.api.TimeAmount; -import org.bukkit.Location; -import org.bukkit.World; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -12,9 +10,6 @@ import org.mockito.junit.MockitoJUnitRunner; import utilities.RandomData; import utilities.Teardown; import utilities.mocks.SystemMockUtil; -import utilities.mocks.objects.MockUtils; - -import java.util.Date; import static org.junit.Assert.*; @@ -42,74 +37,12 @@ public class FormatUtilsTest { assertEquals(expResult, result); } - @Test - public void testFormatTimeAmountSinceDate() { - Date before = new Date(300000L); - Date now = new Date(310000L); - - String expResult = "10s"; - String result = FormatUtils.formatTimeAmountDifference(before.getTime(), now.getTime()); - - assertEquals(expResult, result); - } - @Test public void testFormatTimeAmountMonths() { long time = TimeAmount.DAY.ms() * 40L; assertEquals("1 month, 10d ", FormatUtils.formatTimeAmount(time)); } - @Test - public void testRemoveLetters() { - String dataPoint = "435729847jirggu.eiwb¤#¤%¤#"; - String expResult = "435729847."; - - String result = FormatUtils.removeLetters(dataPoint); - - assertEquals(expResult, result); - } - - @Test - public void testRemoveNumbers() { - String dataPoint = "34532453.5 $"; - String expResult = "$"; - - String result = FormatUtils.removeNumbers(dataPoint); - - assertEquals(expResult, result); - } - - @Test - public void testRemoveNumbers2() { - String dataPoint = "l43r4545tl43 4.5"; - String expResult = "lrtl"; - - String result = FormatUtils.removeNumbers(dataPoint); - - assertEquals(expResult, result); - } - - @Test - public void testParseVersionNumber() { - String versionString = "2.10.2"; - long expResult = 21002000000000000L; - - long result = FormatUtils.parseVersionNumber(versionString); - - assertEquals(expResult, result); - } - - @Test - public void testVersionNumber() { - String versionString = "2.10.2"; - String versionString2 = "2.9.3"; - - long result = FormatUtils.parseVersionNumber(versionString); - long result2 = FormatUtils.parseVersionNumber(versionString2); - - assertTrue("Higher version not higher", result > result2); - } - @Test public void testMergeArrays() { String randomString1 = RandomData.randomString(10); @@ -125,19 +58,6 @@ public class FormatUtilsTest { assertArrayEquals(expResult, result); } - @Test - public void testFormatLocation() { - int randomInt = RandomData.randomInt(0, 100); - - World mockWorld = MockUtils.mockWorld(); - Location loc = new Location(mockWorld, randomInt, randomInt, randomInt); - - String expResult = "x " + randomInt + " z " + randomInt + " in World"; - String result = FormatUtils.formatLocation(loc); - - assertEquals(expResult, result); - } - @Test public void testCutDecimalsWhichIsRoundedDown() { double d = 0.05234;