aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2023-11-04 09:25:36 +0100
committerGitHub <noreply@github.com>2023-11-04 09:25:36 +0100
commitbd42627870b4066b4b8085e17cf67cc7656468f0 (patch)
tree3ba27ec3212201516afe43745950c978c115999a /node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java
parentf547fce384fb465dc04bbbb95063be69b6b89430 (diff)
Revert "Move node-admin"
Diffstat (limited to 'node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java')
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java
new file mode 100644
index 00000000000..79fa1cf6ea2
--- /dev/null
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/StoredBooleanTest.java
@@ -0,0 +1,52 @@
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.node.admin.task.util.file;
+
+import com.yahoo.vespa.hosted.node.admin.component.TaskContext;
+import com.yahoo.vespa.test.file.TestFileSystem;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+
+/**
+ * @author hakonhall
+ */
+public class StoredBooleanTest {
+ private final TaskContext context = mock(TaskContext.class);
+ private final FileSystem fileSystem = TestFileSystem.create();
+ private final Path path = fileSystem.getPath("/foo");
+ private final StoredBoolean storedBoolean = new StoredBoolean(path);
+
+ @Test
+ void storedBoolean() {
+ assertFalse(storedBoolean.value());
+ storedBoolean.set(context);
+ assertTrue(storedBoolean.value());
+ storedBoolean.clear(context);
+ assertFalse(storedBoolean.value());
+ }
+
+ @Test
+ void testCompatibility() throws IOException {
+ StoredInteger storedInteger = new StoredInteger(path);
+ assertFalse(storedBoolean.value());
+
+ storedInteger.write(context, 1);
+ assertTrue(storedBoolean.value());
+
+ storedInteger.write(context, 2);
+ assertTrue(storedBoolean.value());
+
+ storedInteger.write(context, 0);
+ assertFalse(storedBoolean.value());
+
+ Files.delete(path);
+ assertFalse(storedBoolean.value());
+ }
+}