diff options
author | Olli Virtanen <olli.virtanen@oath.com> | 2019-01-03 15:11:03 +0100 |
---|---|---|
committer | Olli Virtanen <olli.virtanen@oath.com> | 2019-01-03 15:11:03 +0100 |
commit | 033182288ab6f4f404a23d1456001d31cb930fc9 (patch) | |
tree | 6d89922ce1505766261b5df7b2656f7528485f42 /container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java | |
parent | b48a97a0814a9a5b6e42ef963f5cb9e2f61d5395 (diff) |
Increased java dispatcher test coverage
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java b/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java new file mode 100644 index 00000000000..92cc79573c8 --- /dev/null +++ b/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java @@ -0,0 +1,45 @@ +// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.search.dispatch; + +import com.yahoo.fs4.QueryPacket; +import com.yahoo.prelude.fastsearch.CacheKey; +import com.yahoo.search.Query; +import com.yahoo.search.Result; +import com.yahoo.search.dispatch.searchcluster.Node; +import com.yahoo.search.result.Coverage; +import com.yahoo.search.searchchain.Execution; + +import java.io.IOException; +import java.util.Optional; + +class MockInvoker extends SearchInvoker { + private final Coverage coverage; + private Query query; + + protected MockInvoker(int key, Coverage coverage) { + super(Optional.of(new Node(key, "?", 0, 0))); + this.coverage = coverage; + } + + protected MockInvoker(int key) { + this(key, null); + } + + @Override + protected void sendSearchRequest(Query query, QueryPacket queryPacket) throws IOException { + this.query = query; + } + + @Override + protected Result getSearchResult(CacheKey cacheKey, Execution execution) throws IOException { + Result ret = new Result(query); + if (coverage != null) { + ret.setCoverage(coverage); + } + return ret; + } + + @Override + protected void release() { + } +}
\ No newline at end of file |