summaryrefslogtreecommitdiffstats
path: root/config-lib/src/test/java/com/yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'config-lib/src/test/java/com/yahoo')
-rw-r--r--config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java20
-rw-r--r--config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java6
-rw-r--r--config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java2
-rw-r--r--config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java43
-rw-r--r--config-lib/src/test/java/com/yahoo/config/StringNodeTest.java4
-rw-r--r--config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java4
6 files changed, 25 insertions, 54 deletions
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 76871aaca42..15e35682980 100644
--- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
@@ -15,7 +15,6 @@ 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;
@@ -257,9 +256,8 @@ public class ConfigInstanceBuilderTest {
assertEquals(configId, config.refwithdef());
assertEquals("etc", config.fileVal().value());
assertEquals(1, config.boolarr().size());
- assertEquals(1, config.boolarr().size()); // new api with accessor for a List of the original Java type
- assertFalse(config.boolarr().get(0)); // new List api
- assertFalse(config.boolarr(0)); // short-hand
+ assertFalse(config.boolarr().get(0));
+ assertFalse(config.boolarr(0)); // shorthand
assertEquals(0, config.intarr().size());
assertEquals(2, config.longarr().size());
assertEquals(Long.MAX_VALUE, config.longarr(0));
@@ -267,7 +265,7 @@ public class ConfigInstanceBuilderTest {
assertEquals(2, config.doublearr().size());
assertEquals(1, config.stringarr().size());
assertEquals(1, config.enumarr().size());
- assertEquals(FunctionTestConfig.Enumarr.VALUES, config.enumarr().get(0)); // new List api, don't have to call value()
+ assertEquals(FunctionTestConfig.Enumarr.VALUES, config.enumarr().get(0));
assertEquals(3, config.refarr().size());
assertEquals(1, config.fileArr().size());
assertEquals(configId, config.refarr(0));
@@ -283,10 +281,10 @@ public class ConfigInstanceBuilderTest {
assertEquals("basicFoo", config.basicStruct().foo());
assertEquals(3, config.basicStruct().bar()); // new List api
assertEquals(2, config.basicStruct().intArr().size());
- assertEquals(310, config.basicStruct().intArr().get(0).intValue()); // new List api
- assertEquals(311, config.basicStruct().intArr().get(1).intValue()); // new List api
- assertEquals(310, config.basicStruct().intArr(0)); // short-hand
- assertEquals("inner0", config.rootStruct().inner0().name()); // new List api
+ assertEquals(310, config.basicStruct().intArr().get(0).intValue());
+ assertEquals(311, config.basicStruct().intArr().get(1).intValue());
+ assertEquals(310, config.basicStruct().intArr(0)); // shorthand
+ assertEquals("inner0", config.rootStruct().inner0().name());
assertEquals(11, config.rootStruct().inner0().index());
assertEquals("inner1", config.rootStruct().inner1().name());
assertEquals(12, config.rootStruct().inner1().index());
@@ -297,8 +295,8 @@ public class ConfigInstanceBuilderTest {
assertEquals("blue a=\"escaped\"", config.rootStruct().innerArr(1).stringVal());
assertEquals(2, config.myarray().size()); // new List api
- assertEquals(configId, config.myarray().get(0).refval()); // new List api
- assertEquals(configId, config.myarray(0).refval()); // short-hand
+ assertEquals(configId, config.myarray().get(0).refval());
+ assertEquals(configId, config.myarray(0).refval()); // shorthand
assertEquals("file0", config.myarray(0).fileVal().value());
assertEquals(1, config.myarray(0).myStruct().a());
assertEquals(2, config.myarray(0).myStruct().b());
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 db1509fba93..4a16eebfeb9 100644
--- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;
-import com.yahoo.test.AppConfig;
import com.yahoo.test.FunctionTestConfig;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -48,11 +47,6 @@ public class ConfigInstanceEqualsTest {
}
@Test
- void require_false_for_different_subclass() {
- assertNotEquals(config1, new AppConfig(new AppConfig.Builder()));
- }
-
- @Test
void require_false_for_different_scalars_at_root_node() {
assertNotEquals(config1, new FunctionTestConfig(newBuilder().bool_val(true)));
assertNotEquals(config1, new FunctionTestConfig(newBuilder().int_val(0)));
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 d53db9fa9c7..da82ec69a62 100644
--- a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
@@ -23,7 +23,7 @@ public class EnumNodeTest {
try {
value = Enum.valueOf(name);
return true;
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException ignored) {
}
return false;
}
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 fb751931062..b5080f76605 100644
--- a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
@@ -4,6 +4,7 @@ package com.yahoo.config;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
+import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -17,72 +18,52 @@ public class NodeVectorTest {
@Test
void require_that_add_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").add(barNode());
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").add(barNode()));
}
@Test
void require_that_addindex_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").add(0, barNode());
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").add(0, barNode()));
}
@Test
void require_that_addAll_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").addAll(Arrays.asList(barNode()));
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").add(barNode()));
}
@Test
void require_that_addAllindex_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").addAll(0, Arrays.asList(barNode()));
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").addAll(0, List.of(barNode())));
}
@Test
void require_that_clear_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").clear();
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").clear());
}
@Test
void require_that_remove_index_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").remove(0);
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").remove(0));
}
@Test
void require_that_remove_object_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").remove(null);
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").remove(null));
}
@Test
void require_that_removeAll_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").removeAll(null);
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").removeAll(null));
}
@Test
void require_that_retainAll_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").retainAll(null);
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").retainAll(null));
}
@Test
void require_that_set_throws_exception() {
- assertThrows(NodeVector.ReadOnlyException.class, () -> {
- new TestNodeVector("foo").set(0, null);
- });
+ assertThrows(NodeVector.ReadOnlyException.class, () -> new TestNodeVector("foo").set(0, null));
}
@Test
@@ -91,7 +72,7 @@ public class NodeVectorTest {
TestNodeVector v = new TestNodeVector(val.getValue());
assertTrue(v.contains(val));
assertFalse(v.contains(barNode()));
- assertTrue(v.containsAll(Arrays.asList(val)));
+ assertTrue(v.contains(val));
assertFalse(v.containsAll(Arrays.asList(val, barNode())));
}
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 3470c96bbcc..7211f8ad776 100644
--- a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
@@ -23,9 +23,7 @@ public class StringNodeTest {
@Test
void testUnescapedQuotedStringExceptions() {
- assertThrows(IllegalArgumentException.class, () -> {
- StringNode.unescapeQuotedString("foo\\");
- });
+ assertThrows(IllegalArgumentException.class, () -> StringNode.unescapeQuotedString("foo\\"));
}
@Test
diff --git a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
index 39e5f64e5e2..8d15832b73a 100644
--- a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
@@ -12,8 +12,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* @author gjoranv
*/
public class NamespaceAndPackageTest {
- private static String NAMESPACE = "my.namespace";
- private static String PACKAGE = "com.github.myproject";
+ private static final String NAMESPACE = "my.namespace";
+ private static final String PACKAGE = "com.github.myproject";
@Test
void namespace_is_set_from_def_file() {