✅ Add test for WatchGlobal
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 7 Jan 2025 06:45:14 +0000 (07:45 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 7 Jan 2025 06:45:14 +0000 (07:45 +0100)
src/test/java/net/pterodactylus/fcp/WatchGlobalTest.java [new file with mode: 0644]

diff --git a/src/test/java/net/pterodactylus/fcp/WatchGlobalTest.java b/src/test/java/net/pterodactylus/fcp/WatchGlobalTest.java
new file mode 100644 (file)
index 0000000..41cdecc
--- /dev/null
@@ -0,0 +1,48 @@
+package net.pterodactylus.fcp;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+public class WatchGlobalTest {
+
+       @Test
+       public void watchGlobalMessageWithOneArgumentHasCorrectName() {
+               WatchGlobal watchGlobal = new WatchGlobal(true);
+               assertThat(watchGlobal.getName(), equalTo("WatchGlobal"));
+       }
+
+       @Test
+       public void watchGlobalMessageWithOneArgumentTrueHasEnabledFieldSetToTrue() {
+               WatchGlobal watchGlobal = new WatchGlobal(true);
+               assertThat(watchGlobal.getField("Enabled"), equalTo("true"));
+       }
+
+       @Test
+       public void watchGlobalMessageWithOneArgumentFalseHasEnabledFieldSetToFalse() {
+               WatchGlobal watchGlobal = new WatchGlobal(false);
+               assertThat(watchGlobal.getField("Enabled"), equalTo("false"));
+       }
+
+       @Test
+       public void watchGlobalMessageWithTwoArgumentsHasCorrectName() {
+               WatchGlobal watchGlobal = new WatchGlobal(true, Verbosity.ALL);
+               assertThat(watchGlobal.getName(), equalTo("WatchGlobal"));
+       }
+
+       @Test
+       public void watchGlobalMessageWithTwoArgumentsTrueAndAllHasTheCorrectFieldsSet() {
+               WatchGlobal watchGlobal = new WatchGlobal(true, Verbosity.ALL);
+               assertThat(watchGlobal.getField("Enabled"), equalTo("true"));
+               assertThat(watchGlobal.getField("VerbosityMask"), equalTo("-1"));
+       }
+
+       @Test
+       public void watchGlobalMessageWithTwoArgumentsFalseAndCompressionHasTheCorrectFieldsSet() {
+               WatchGlobal watchGlobal = new WatchGlobal(false, Verbosity.COMPRESSION);
+               assertThat(watchGlobal.getField("Enabled"), equalTo("false"));
+               assertThat(watchGlobal.getField("VerbosityMask"), equalTo("512"));
+       }
+
+}