diff options
Diffstat (limited to 'config-lib/src/test/java')
12 files changed, 56 insertions, 13 deletions
diff --git a/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java b/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java index 50d71ba50e9..4d6b39f3976 100644 --- a/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java @@ -8,9 +8,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen - * @since 5.1 */ public class BooleanNodeTest { + @Test void testSetValue() { BooleanNode n = new BooleanNode(); @@ -21,4 +21,5 @@ public class BooleanNodeTest { assertFalse(n.doSetValue("FALSEa")); assertFalse(n.doSetValue("aFALSE")); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java index f05baeff08c..d1cd7678911 100644 --- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java +++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java @@ -15,6 +15,7 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import static com.yahoo.foo.StructtypesConfig.Simple.Gender.Enum.FEMALE; import static com.yahoo.test.FunctionTestConfig.BasicStruct; @@ -34,10 +35,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author gjoranv - * @since 5.1.11 */ -public class ConfigInstanceBuilderTest -{ +public class ConfigInstanceBuilderTest { @Test void struct_values_can_be_set_without_declaring_a_new_struct_builder() { @@ -170,6 +169,9 @@ public class ConfigInstanceBuilderTest fileVal("etc"). pathVal(FileReference.mockFileReferenceForUnitTesting(new File("pom.xml"))). urlVal(new UrlReference("http://docs.vespa.ai")). + modelVal(new ModelReference(Optional.empty(), + Optional.empty(), + Optional.of(FileReference.mockFileReferenceForUnitTesting(new File("pom.xml"))))). boolarr(false). longarr(9223372036854775807L). longarr(-9223372036854775808L). @@ -408,4 +410,5 @@ public class ConfigInstanceBuilderTest report.toString().contains("function-test.myStructMap{one} with value \n") ); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java index 1584293a137..1a05c08d8f2 100644 --- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java +++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test; import java.io.File; import java.util.Arrays; +import java.util.Optional; import static com.yahoo.test.FunctionTestConfig.BasicStruct; import static com.yahoo.test.FunctionTestConfig.Enum_val; @@ -18,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; public class ConfigInstanceEqualsTest { + FunctionTestConfig config1; FunctionTestConfig.Builder builder2; FunctionTestConfig config2; @@ -130,6 +132,9 @@ public class ConfigInstanceEqualsTest { fileVal("etc"). pathVal(FileReference.mockFileReferenceForUnitTesting(new File("pom.xml"))). urlVal(new UrlReference("http://docs.vespa.ai")). + modelVal(new ModelReference(Optional.of("my-model-id"), + Optional.of(new UrlReference("http://docs.vespa.ai")), + Optional.empty())). boolarr(false). longarr(9223372036854775807L). longarr(-9223372036854775808L). @@ -140,6 +145,9 @@ public class ConfigInstanceEqualsTest { refarr(Arrays.asList(":parent:", ":parent", "parent:")). // test collection based setter fileArr("bin"). urlArr(new UrlReference("http://docs.vespa.ai")). + modelArr(new ModelReference(Optional.empty(), + Optional.of(new UrlReference("http://docs.vespa.ai")), + Optional.of(FileReference.mockFileReferenceForUnitTesting(new File("pom.xml"))))). basicStruct(new BasicStruct.Builder(). foo("basicFoo"). @@ -183,4 +191,5 @@ public class ConfigInstanceEqualsTest { b(-2))); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java index 475a33104b0..ae9894041f9 100644 --- a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java @@ -10,9 +10,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen - * @since 5.1 */ public class DoubleNodeTest { + @Test void testSetValue() { DoubleNode n = new DoubleNode(); @@ -20,4 +20,5 @@ public class DoubleNodeTest { assertTrue(n.doSetValue("3.14")); assertEquals(3.14, n.value(), 0.001); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java index e7723409736..d53db9fa9c7 100644 --- a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java @@ -12,6 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * @author Ulf Lilleengen */ public class EnumNodeTest { + private static class MyNode extends EnumNode<MyNode.Enum> { public enum Enum { ONE, TWO } public final static Enum ONE = Enum.ONE; @@ -39,4 +40,5 @@ public class EnumNodeTest { assertEquals("ONE", n.toString()); assertFalse(n.doSetValue("THREE")); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java index 8bec9378f8f..49796c795a9 100644 --- a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java @@ -9,7 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen - * @since 5.1 */ public class FileNodeTest { @@ -23,7 +22,7 @@ public class FileNodeTest { assertEquals("foo.txt", n.value().value()); assertEquals("\"foo.txt\"", n.toString()); - assertEquals("path may not start with '..', but got: foo/../../boo", + assertEquals("Path may not start with '..' but got 'foo/../../boo'", assertThrows(IllegalArgumentException.class, () -> new FileNode("foo/../../boo")).getMessage()); } diff --git a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java index a195a5f65fb..4081192d2e8 100644 --- a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java @@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen - * @since 5.1 */ public class IntegerNodeTest { + @Test void testSetValue() { IntegerNode n = new IntegerNode(); @@ -19,4 +19,5 @@ public class IntegerNodeTest { assertTrue(n.setValue("10")); assertEquals(10, n.value().intValue()); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java index dc6d59bbc46..9e021edd3a8 100644 --- a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java @@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen - * @since 5.1 */ public class LongNodeTest { + @Test void testSetValue() { LongNode n = new LongNode(); @@ -19,4 +19,5 @@ public class LongNodeTest { assertTrue(n.setValue("10")); assertEquals(10L, n.value().longValue()); } + } diff --git a/config-lib/src/test/java/com/yahoo/config/ModelNodeTest.java b/config-lib/src/test/java/com/yahoo/config/ModelNodeTest.java new file mode 100644 index 00000000000..696e0722714 --- /dev/null +++ b/config-lib/src/test/java/com/yahoo/config/ModelNodeTest.java @@ -0,0 +1,29 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config; + +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author bratseth + */ +public class ModelNodeTest { + + @Test + void testEmpty() { + assertEquals("(null)", new ModelNode().toString()); + } + + @Test + void testReference() { + var reference = new ModelReference(Optional.of("myModelId"), + Optional.of(new UrlReference("https://host:my/path")), + Optional.of(new FileReference("foo.txt"))); + assertEquals("myModelId https://host:my/path foo.txt", reference.toString()); + assertEquals(reference, ModelReference.valueOf(reference.toString())); + } + +} diff --git a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java index e6b3b4b6a71..fb751931062 100644 --- a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java +++ b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java @@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Ulf Lilleengen - * @since 5.1 */ public class NodeVectorTest { diff --git a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java index ad8f5e2e65f..622466d95a2 100644 --- a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java @@ -10,7 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author gjoranv - * @since 5.1.28 */ public class PathNodeTest { @@ -22,7 +21,7 @@ public class PathNodeTest { n = new PathNode(new FileReference("foo.txt")); assertEquals(new File("foo.txt").toPath(), n.value()); - assertEquals("path may not start with '..', but got: foo/../../boo", + assertEquals("Path may not start with '..' but got 'foo/../../boo'", assertThrows(IllegalArgumentException.class, () -> new PathNode(new FileReference("foo/../../boo"))).getMessage()); } diff --git a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java index d0baf8d1837..3470c96bbcc 100644 --- a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java @@ -8,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author hmusum - * @since 5.1.7 */ public class StringNodeTest { |