From 6c0613f36f23cb82b3d75801e6e5ae6753f2dc50 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 25 Apr 2017 09:52:12 +0200 Subject: [PATCH] fix mocking in tests Original commit: elastic/x-pack-elasticsearch@b43de1ea2b2e3e406f965b10e363f5c6eefb5028 --- .../SecurityIndexSearcherWrapperUnitTests.java | 11 ++++------- .../transform/script/ScriptTransformTests.java | 4 +--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java index 9d4a7ff3c1e..50edc0f538b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java @@ -68,13 +68,12 @@ import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.TermsLookup; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.script.CompiledScript; -import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.aggregations.LeafBucketCollector; +import org.elasticsearch.template.CompiledTemplate; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.elasticsearch.xpack.security.authz.accesscontrol.DocumentSubsetReader.DocumentSubsetDirectoryReader; @@ -458,10 +457,8 @@ public class SecurityIndexSearcherWrapperUnitTests extends ESTestCase { } }; - CompiledScript compiledScript = mock(CompiledScript.class); - when(scriptService.compile(any(Script.class), eq(ScriptContext.Standard.SEARCH))).thenReturn(compiledScript); - ExecutableScript executableScript = mock(ExecutableScript.class); - when(scriptService.executable(eq(compiledScript), any())).thenReturn(executableScript); + CompiledTemplate compiledScript = mock(CompiledTemplate.class); + when(scriptService.compileTemplate(any(Script.class), eq(ScriptContext.Standard.SEARCH))).thenReturn(compiledScript); XContentBuilder builder = jsonBuilder(); String query = new TermQueryBuilder("field", "{{_user.username}}").toXContent(builder, ToXContent.EMPTY_PARAMS).string(); @@ -472,7 +469,7 @@ public class SecurityIndexSearcherWrapperUnitTests extends ESTestCase { securityIndexSearcherWrapper.evaluateTemplate(querySource); ArgumentCaptor