From bd24e12026abcb464ba49047a86863b3cb4d3b32 Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 7 May 2018 10:39:22 +0200 Subject: [PATCH] Add override tests. --- .../test/TestWorldDataManager.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestWorldDataManager.java b/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestWorldDataManager.java index c05a54c2..66ca1916 100644 --- a/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestWorldDataManager.java +++ b/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestWorldDataManager.java @@ -31,6 +31,7 @@ import fr.neatmonster.nocheatplus.config.ConfPaths; import fr.neatmonster.nocheatplus.config.ConfigFile; import fr.neatmonster.nocheatplus.config.DefaultConfig; import fr.neatmonster.nocheatplus.logging.StaticLog; +import fr.neatmonster.nocheatplus.worlds.IWorldData; import fr.neatmonster.nocheatplus.worlds.WorldDataManager; public class TestWorldDataManager { @@ -84,7 +85,7 @@ public class TestWorldDataManager { WorldDataManager worldMan = getWorldDataManager(); - final Map rawWorldConfigs = new LinkedHashMap(); + Map rawWorldConfigs = new LinkedHashMap(); // (Implicitly create configurations via set). // Default. @@ -196,6 +197,44 @@ public class TestWorldDataManager { fail("Overridden (SPECIFIC): COMBINED_MUNCHHAUSEN should be active after reload (COMBINED is)"); } + ////////////////////////////////////////////////////////////////////// + + /////////////////// + // Reset + /////////////////// + + worldMan = getWorldDataManager(); + rawWorldConfigs = new LinkedHashMap(); + set(rawWorldConfigs, null, "dummy", "dummy"); + worldMan.applyConfiguration(rawWorldConfigs); + + IWorldData defaultWorldData = worldMan.getDefaultWorldData(); + + // Set all to NO. + defaultWorldData.overrideCheckActivation(CheckType.ALL, AlmostBoolean.NO, + OverrideType.VOLATILE, true); + for (CheckType checkType : CheckType.values()) { + if (defaultWorldData.isCheckActive(checkType)) { + fail("Expect check not to be active: " + checkType); + } + } + + // Set all to YES. + defaultWorldData.overrideCheckActivation(CheckType.ALL, AlmostBoolean.YES, + OverrideType.VOLATILE, true); + for (CheckType checkType : CheckType.values()) { + if (!defaultWorldData.isCheckActive(checkType)) { + fail("Expect check to be active: " + checkType); + } + } + + // Set FastHeal to NO + defaultWorldData.overrideCheckActivation(CheckType.FIGHT_FASTHEAL, AlmostBoolean.NO, + OverrideType.VOLATILE, true); + if (defaultWorldData.isCheckActive(CheckType.FIGHT_FASTHEAL)) { + fail("Expect FIGHT_FASTHEAL not to be active."); + } + } }