diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-10-15 15:27:00 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-10-15 15:27:00 +0200 |
commit | 2c7a55d649027e725b753d530fa02845ca8bce97 (patch) | |
tree | 3d06272e1d2c9031a92c4ad40004f29afeaaafef /container-search | |
parent | 40dfba74d104736de612e3cbdd0595acc7dc83ea (diff) |
Avoid deprecated method
Diffstat (limited to 'container-search')
3 files changed, 20 insertions, 19 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java index 594c1e3fca0..4da84394435 100644 --- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java +++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java @@ -319,7 +319,7 @@ public class IndexFacts { * @deprecated set indexes at creation time instead */ // TODO: Remove on Vespa 7 - @Deprecated + @Deprecated // OK public void addIndex(String sdName, String indexName) { ensureNotFrozen(); diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java index 2b414421810..8c59b20a5dd 100644 --- a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java @@ -74,11 +74,6 @@ public class IndexFactsTestCase { assertEquals("a:b", q.getModel().getQueryTree().getRoot().toString()); q = newQuery("?query=notarealindex:b", indexFacts); assertEquals("\"notarealindex b\"", q.getModel().getQueryTree().getRoot().toString()); - - // Add an index to an SD which also happens to be the default - indexFacts.addIndex("one", "yetanothersynthetic"); - q = newQuery("?query=yetanothersynthetic:b", indexFacts); - assertEquals("yetanothersynthetic:b", q.getModel().getQueryTree().getRoot().toString()); } @Test diff --git a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java index 2d46ff8e177..627dbb13cbe 100644 --- a/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/test/QueryTestCase.java @@ -4,7 +4,10 @@ package com.yahoo.prelude.test; import com.yahoo.language.Language; import com.yahoo.language.Linguistics; import com.yahoo.language.simple.SimpleLinguistics; +import com.yahoo.prelude.Index; import com.yahoo.prelude.IndexFacts; +import com.yahoo.prelude.IndexModel; +import com.yahoo.prelude.SearchDefinition; import com.yahoo.prelude.query.QueryException; import com.yahoo.prelude.query.WordItem; import com.yahoo.search.Query; @@ -16,6 +19,7 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import java.util.Collections; import java.util.List; import static org.hamcrest.CoreMatchers.containsString; @@ -31,18 +35,6 @@ import static org.junit.Assume.assumeTrue; */ public class QueryTestCase { - private final IndexFacts facts = new IndexFacts(); - - @Before - public void setUp() { - // Setup the indices we expect - facts.addIndex(null,"fast.type"); - facts.addIndex(null,"def"); - facts.addIndex(null,"default"); - facts.addIndex(null,"keyword"); - facts.addIndex(null,"content"); - } - /** * Basic test */ @@ -377,9 +369,23 @@ public class QueryTestCase { return newQueryFromEncoded(com.yahoo.search.test.QueryTestCase.httpEncode(queryString), language, linguistics); } + private IndexFacts createIndexFacts() { + SearchDefinition sd = new SearchDefinition("test"); + sd.addIndex(new Index("fast.type")); + sd.addIndex(new Index("def")); + sd.addIndex(new Index("default")); + sd.addIndex(new Index("keyword")); + sd.addIndex(new Index("content")); + return new IndexFacts(new IndexModel(Collections.emptyMap(), Collections.singleton(sd))); + } + private Query newQueryFromEncoded(String encodedQueryString, Language language, Linguistics linguistics) { Query query = new Query(encodedQueryString); - query.getModel().setExecution(new Execution(new Execution.Context(null, facts, null, null, linguistics))); + query.getModel().setExecution(new Execution(new Execution.Context(null, + createIndexFacts(), + null, + null, + linguistics))); query.getModel().setLanguage(language); return query; } |