Change use of generics in test

Original commit: elastic/x-pack-elasticsearch@39473681b2
This commit is contained in:
Chris Earle 2016-08-17 15:50:20 -04:00
parent c16860e901
commit 572869087d

View File

@ -15,18 +15,21 @@ import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
public class WatcherScriptTests extends ESTestCase { public class WatcherScriptTests extends ESTestCase {
public void testParseScript() throws IOException { public void testParseScript() throws IOException {
final Map<String, Object> params =
randomFrom(Collections.<String, Object>emptyMap(), Collections.singletonMap("foo", (Object)"bar"), null);
WatcherScript script = new WatcherScript(randomAsciiOfLengthBetween(1, 5), WatcherScript script = new WatcherScript(randomAsciiOfLengthBetween(1, 5),
randomFrom(ScriptType.values()), randomFrom(ScriptType.values()),
randomBoolean() ? null : randomFrom("custom", "mustache"), randomFrom("custom", "mustache", null),
randomBoolean() ? null : randomFrom(emptyMap(), singletonMap("foo", "bar"))); params);
try (XContentParser parser = createParser(script)) { try (XContentParser parser = createParser(script)) {
assertThat(WatcherScript.parse(parser), equalTo(script)); assertThat(WatcherScript.parse(parser), equalTo(script));