mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
[Debt] Removed Settings#setTemporaryValue method.
This method was used in tests, but is not the optimal way of performing temporary test values as APF supports in memory configuration object. Old usages were commented in order to preserve assumed temporary values. Affected issues: none
This commit is contained in:
parent
2b1cf4b3cb
commit
fca93578af
|
@ -101,25 +101,14 @@ public enum Settings implements Setting {
|
|||
BUNGEE_NETWORK_NAME("Network.Name");
|
||||
|
||||
private final String configPath;
|
||||
private Object tempValue;
|
||||
|
||||
Settings(String path) {
|
||||
this.configPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the String path of a the config setting eg.
|
||||
* Settings.WebServer.Enabled
|
||||
*
|
||||
* @return Path of the config setting.
|
||||
*/
|
||||
@Override
|
||||
public String getPath() {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTemporaryValue(Object value) {
|
||||
this.tempValue = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,13 @@ package com.djrapitops.plan.system.settings.config;
|
|||
*/
|
||||
public interface Setting {
|
||||
|
||||
/**
|
||||
* Used to get the String path of a the config setting.
|
||||
* <p>
|
||||
* Path separates nested levels with a dot.
|
||||
*
|
||||
* @return Example: Settings.WebServer.Enabled
|
||||
*/
|
||||
String getPath();
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.junit.ClassRule;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +20,6 @@ public class FormattersTest {
|
|||
public static void setUpClass() throws Exception {
|
||||
SystemMockUtil.setUp(temporaryFolder.getRoot())
|
||||
.enableConfigSystem();
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -6,12 +6,10 @@ package com.djrapitops.plan.system;
|
|||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.BukkitMockUtil;
|
||||
|
||||
/**
|
||||
|
@ -38,23 +36,17 @@ public class BukkitSystemTest {
|
|||
planMock = mockUtil.getPlanMock();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (bukkitSystem != null) {
|
||||
bukkitSystem.disable();
|
||||
}
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEnable() throws EnableException {
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
|
||||
bukkitSystem = null; //TODO
|
||||
bukkitSystem.enable();
|
||||
|
|
|
@ -8,13 +8,11 @@ import com.djrapitops.plan.Plan;
|
|||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.BukkitMockUtil;
|
||||
import utilities.mocks.BungeeMockUtil;
|
||||
|
||||
|
@ -59,13 +57,6 @@ public class BungeeBukkitConnectionTest {
|
|||
bungeeMock = bungeeMockUtil.getPlanMock();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
Settings.DEBUG.setTemporaryValue("console");
|
||||
Settings.DEV_MODE.setTemporaryValue(true);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
System.out.println("------------------------------");
|
||||
|
@ -77,11 +68,10 @@ public class BungeeBukkitConnectionTest {
|
|||
if (bungeeSystem != null) {
|
||||
bungeeSystem.disable();
|
||||
}
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
public void enable() throws EnableException {
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
|
||||
bukkitSystem = null; // TODO
|
||||
bukkitSystem.enable();
|
||||
|
@ -90,9 +80,9 @@ public class BungeeBukkitConnectionTest {
|
|||
|
||||
bungeeSystem = null; // TODO
|
||||
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9250);
|
||||
Settings.BUNGEE_IP.setTemporaryValue("localhost");
|
||||
Settings.DB_TYPE.setTemporaryValue("sqlite");
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9250);
|
||||
// Settings.BUNGEE_IP.setTemporaryValue("localhost");
|
||||
// Settings.DB_TYPE.setTemporaryValue("sqlite");
|
||||
// bungeeSystem.setDatabaseSystem(new BukkitDBSystem(new Locale()));
|
||||
|
||||
bungeeSystem.enable();
|
||||
|
|
|
@ -6,13 +6,11 @@ package com.djrapitops.plan.system;
|
|||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.BungeeMockUtil;
|
||||
|
||||
/**
|
||||
|
@ -40,19 +38,12 @@ public class BungeeSystemTest {
|
|||
.withProxy();
|
||||
planMock = mockUtil.getPlanMock();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (bungeeSystem != null) {
|
||||
bungeeSystem.disable();
|
||||
}
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,9 +51,9 @@ public class BungeeSystemTest {
|
|||
public void testEnable() throws EnableException {
|
||||
bungeeSystem = null; //TODO
|
||||
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
Settings.BUNGEE_IP.setTemporaryValue("8.8.8.8");
|
||||
Settings.DB_TYPE.setTemporaryValue("sqlite");
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.BUNGEE_IP.setTemporaryValue("8.8.8.8");
|
||||
// Settings.DB_TYPE.setTemporaryValue("sqlite");
|
||||
// bungeeSystem.setDatabaseSystem(new BukkitDBSystem(Locale::new));
|
||||
|
||||
bungeeSystem.enable();
|
||||
|
@ -76,8 +67,8 @@ public class BungeeSystemTest {
|
|||
|
||||
bungeeSystem = null; //TODO
|
||||
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
Settings.DB_TYPE.setTemporaryValue("sqlite");
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.DB_TYPE.setTemporaryValue("sqlite");
|
||||
// bungeeSystem.setDatabaseSystem(new BukkitDBSystem(Locale::new));
|
||||
|
||||
bungeeSystem.enable();
|
||||
|
|
|
@ -6,12 +6,10 @@ package com.djrapitops.plan.system;
|
|||
|
||||
import com.djrapitops.plan.PlanSponge;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.SpongeMockUtil;
|
||||
|
||||
/**
|
||||
|
@ -36,23 +34,17 @@ public class SpongeSystemTest {
|
|||
planMock = mockUtil.getPlanMock();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (spongeSystem != null) {
|
||||
spongeSystem.disable();
|
||||
}
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Sponge mock required")
|
||||
public void testEnable() throws EnableException {
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
|
||||
spongeSystem = null; //TODO
|
||||
spongeSystem.enable();
|
||||
|
|
|
@ -3,11 +3,12 @@ package com.djrapitops.plan.system.cache;
|
|||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import org.junit.*;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.BukkitMockUtil;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -25,7 +26,6 @@ public class GeolocationCacheTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
Teardown.resetSettingsTempValues();
|
||||
BukkitMockUtil mockUtil = BukkitMockUtil.setUp()
|
||||
.withDataFolder(temporaryFolder.getRoot())
|
||||
.withLogging()
|
||||
|
@ -36,15 +36,10 @@ public class GeolocationCacheTest {
|
|||
StaticHolder.saveInstance(GeolocationCacheTest.class, planMock.getClass());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testGeolocationCache() throws EnableException {
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
PlanSystem system = null; //TODO
|
||||
try {
|
||||
system.enable();
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.OptionalAssert;
|
||||
import utilities.RandomData;
|
||||
import utilities.Teardown;
|
||||
import utilities.TestConstants;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
|
@ -81,7 +80,6 @@ public class SQLiteTest {
|
|||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -5,14 +5,10 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|||
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.Teardown;
|
||||
import utilities.TestConstants;
|
||||
import utilities.TestErrorManager;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -25,7 +21,6 @@ public class NetworkSettingsTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
Teardown.resetSettingsTempValues();
|
||||
StaticHolder.saveInstance(NetworkSettingsTest.class, Plan.class);
|
||||
|
||||
SystemMockUtil mockUtil = SystemMockUtil.setUp(temporaryFolder.getRoot())
|
||||
|
@ -34,9 +29,9 @@ public class NetworkSettingsTest {
|
|||
mockUtil.enableDatabaseSystem(db)
|
||||
.enableServerInfoSystem();
|
||||
|
||||
Log.setErrorManager(new TestErrorManager());
|
||||
Log.setDebugMode("console");
|
||||
Settings.DEV_MODE.setTemporaryValue(true);
|
||||
// Log.setErrorManager(new TestErrorManager());
|
||||
// Log.setDebugMode("console");
|
||||
// Settings.DEV_MODE.setTemporaryValue(true);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -44,7 +39,6 @@ public class NetworkSettingsTest {
|
|||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.djrapitops.plan.system.webserver;
|
|||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.BukkitMockUtil;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
|
@ -41,12 +39,12 @@ public class HTTPSWebServerAuthTest {
|
|||
String keyStore = resource.getPath();
|
||||
String absolutePath = new File(keyStore).getAbsolutePath();
|
||||
|
||||
Settings.WEBSERVER_CERTIFICATE_PATH.setTemporaryValue(absolutePath);
|
||||
Settings.WEBSERVER_CERTIFICATE_KEYPASS.setTemporaryValue("MnD3bU5HpmPXag0e");
|
||||
Settings.WEBSERVER_CERTIFICATE_STOREPASS.setTemporaryValue("wDwwf663NLTm73gL");
|
||||
Settings.WEBSERVER_CERTIFICATE_ALIAS.setTemporaryValue("DefaultPlanCert");
|
||||
|
||||
Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
// Settings.WEBSERVER_CERTIFICATE_PATH.setTemporaryValue(absolutePath);
|
||||
// Settings.WEBSERVER_CERTIFICATE_KEYPASS.setTemporaryValue("MnD3bU5HpmPXag0e");
|
||||
// Settings.WEBSERVER_CERTIFICATE_STOREPASS.setTemporaryValue("wDwwf663NLTm73gL");
|
||||
// Settings.WEBSERVER_CERTIFICATE_ALIAS.setTemporaryValue("DefaultPlanCert");
|
||||
//
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
|
||||
bukkitSystem = null; //TODO
|
||||
// bukkitSystem.enable();
|
||||
|
@ -55,16 +53,6 @@ public class HTTPSWebServerAuthTest {
|
|||
// .webUser(new WebUser("test", PassEncryptUtil.createHash("testPass"), 0));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
if (bukkitSystem != null) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -30,7 +29,6 @@ public class PlayersTableTest {
|
|||
public static void setUpClass() throws Exception {
|
||||
SystemMockUtil.setUp(temporaryFolder.getRoot())
|
||||
.enableConfigSystem();
|
||||
Teardown.resetSettingsTempValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package utilities;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
|
||||
/**
|
||||
* Test utility for {@code @Teardown} tags.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Teardown {
|
||||
|
||||
public static void resetSettingsTempValues() {
|
||||
for (Settings settings : Settings.values()) {
|
||||
settings.setTemporaryValue(null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.TestConstants;
|
||||
import utilities.mocks.objects.FakeConsoleCmdSender;
|
||||
import utilities.mocks.objects.TestLogger;
|
||||
|
@ -41,7 +40,6 @@ public class BukkitMockUtil extends MockUtil {
|
|||
}
|
||||
|
||||
public static BukkitMockUtil setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
return new BukkitMockUtil().mockPlugin();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import net.md_5.bungee.api.plugin.PluginDescription;
|
|||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.TestConstants;
|
||||
import utilities.mocks.objects.FakeBungeeConsole;
|
||||
import utilities.mocks.objects.TestLogger;
|
||||
|
@ -41,7 +40,6 @@ public class BungeeMockUtil extends MockUtil {
|
|||
}
|
||||
|
||||
public static BungeeMockUtil setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
return new BungeeMockUtil().mockPlugin();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.djrapitops.plugin.task.thread.ThreadRunnable;
|
|||
import com.djrapitops.plugin.task.thread.ThreadRunnableFactory;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.objects.TestLogger;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -32,7 +31,6 @@ public class SpongeMockUtil extends MockUtil {
|
|||
}
|
||||
|
||||
public static SpongeMockUtil setUp() {
|
||||
Teardown.resetSettingsTempValues();
|
||||
return new SpongeMockUtil().mockPlugin();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user