summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-09-01 15:34:21 +0200
committerJon Bratseth <bratseth@gmail.com>2022-09-01 15:34:21 +0200
commit38bfeeadafabeeef540157e440224b03ba80ed4d (patch)
treebb0a1ea8fd6f9ee4c3289eaf0df821288569649f /config
parent86a39ab21db4a92b46944709251ccab58ef39370 (diff)
Add test
Diffstat (limited to 'config')
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java4
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigPayloadApplierTest.java49
-rw-r--r--config/src/test/resources/configs/def-files/resolved-types.def6
3 files changed, 56 insertions, 3 deletions
diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java b/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java
index e68e996fc97..259a5ef9e6b 100644
--- a/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java
+++ b/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java
@@ -10,7 +10,6 @@ import com.yahoo.slime.ArrayTraverser;
import com.yahoo.slime.Inspector;
import com.yahoo.slime.ObjectTraverser;
import com.yahoo.slime.Type;
-import com.yahoo.yolean.Exceptions;
import java.io.File;
import java.lang.reflect.Constructor;
@@ -62,8 +61,7 @@ public class ConfigPayloadApplier<T extends ConfigInstance.Builder> {
try {
handleValue(payload.getSlime().get());
} catch (Exception e) {
- throw new RuntimeException("Not able to create config builder for payload:" + payload.toString() +
- ", " + Exceptions.toMessageString(e), e);
+ throw new RuntimeException("Not able to create config builder for payload '" + payload.toString() + "'", e);
}
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadApplierTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadApplierTest.java
new file mode 100644
index 00000000000..4d3b6b93b3b
--- /dev/null
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadApplierTest.java
@@ -0,0 +1,49 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config;
+
+import com.yahoo.config.FileReference;
+import com.yahoo.config.ModelReference;
+import com.yahoo.config.ResolvedTypesConfig;
+import com.yahoo.config.UrlReference;
+import org.junit.Test;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.util.Optional;
+
+/**
+ * @author bratseth
+ */
+public class ConfigPayloadApplierTest {
+
+ @Test
+ public void testConfigApplier() {
+ var applier = new ConfigPayloadApplier<>(new ResolvedTypesConfig.Builder(), new MockAcquirer(), new MockDownloader());
+ var config = new ResolvedTypesConfig.Builder();
+ config.myPath(new FileReference("mock/myPath.txt"));
+ config.myUrl(new UrlReference("mock/myUrl.txt"));
+ config.myModel(new ModelReference(Optional.empty(),
+ Optional.of(new UrlReference("mockPath/myPath.txt")),
+ Optional.of(new FileReference("mockUrl/myUrl.txt"))));
+ applier.applyPayload(ConfigPayload.fromInstance(config.build()));
+ }
+
+ private static class MockAcquirer implements ConfigTransformer.PathAcquirer {
+
+ @Override
+ public Path getPath(FileReference fileReference) {
+ return Path.of("mockPath", fileReference.value());
+ }
+
+ }
+
+ private static class MockDownloader extends UrlDownloader {
+
+ @Override
+ public File waitFor(UrlReference urlReference, long timeout) {
+ return new File("mockUrl", urlReference.value());
+ }
+
+ }
+
+}
diff --git a/config/src/test/resources/configs/def-files/resolved-types.def b/config/src/test/resources/configs/def-files/resolved-types.def
new file mode 100644
index 00000000000..184e98d51d9
--- /dev/null
+++ b/config/src/test/resources/configs/def-files/resolved-types.def
@@ -0,0 +1,6 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+namespace=config
+
+myPath path
+myUrl url
+myModel model