summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java b/container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java
new file mode 100644
index 00000000000..7684e55eabc
--- /dev/null
+++ b/container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java
@@ -0,0 +1,31 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.prelude;
+
+import com.yahoo.config.subscription.ConfigGetter;
+import com.yahoo.config.ConfigInstance;
+import com.yahoo.search.config.IndexInfoConfig;
+import com.yahoo.container.QrSearchersConfig;
+
+/**
+ * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
+ */
+public abstract class IndexFactsFactory {
+
+ public static IndexFacts newInstance(String configId) {
+ return new IndexFacts(new IndexModel(resolveConfig(IndexInfoConfig.class, configId),
+ resolveConfig(QrSearchersConfig.class, configId)));
+
+ }
+
+ public static IndexFacts newInstance(String indexInfoConfigId, String qrSearchersConfigId) {
+ return new IndexFacts(new IndexModel(resolveConfig(IndexInfoConfig.class, indexInfoConfigId),
+ resolveConfig(QrSearchersConfig.class, qrSearchersConfigId)));
+
+ }
+
+ private static <T extends ConfigInstance> T resolveConfig(Class<T> configClass, String configId) {
+ if (configId == null) return null;
+ return ConfigGetter.getConfig(configClass, configId);
+ }
+
+}