diff --git a/x-pack/plugin/watcher/build.gradle b/x-pack/plugin/watcher/build.gradle index c03fa35f55685..4a22191638d39 100644 --- a/x-pack/plugin/watcher/build.gradle +++ b/x-pack/plugin/watcher/build.gradle @@ -13,10 +13,6 @@ archivesBaseName = 'x-pack-watcher' ext.compactProfile = 'full' -tasks.withType(JavaCompile).configureEach { - options.compilerArgs << "-Xlint:-rawtypes,-unchecked" -} - tasks.named("dependencyLicenses").configure { mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer' } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index cf3012202cceb..87e0947fd4316 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -238,7 +238,7 @@ public class Watcher extends Plugin implements SystemIndexPlugin, ScriptPlugin, protected final Settings settings; protected final boolean enabled; - protected List reloadableServices = new ArrayList<>(); + protected List> reloadableServices = new ArrayList<>(); public Watcher(final Settings settings) { this.settings = settings; @@ -292,7 +292,7 @@ public Collection createComponents(Client client, ClusterService cluster reloadableServices.add(pagerDutyService); TextTemplateEngine templateEngine = new TextTemplateEngine(scriptService); - Map emailAttachmentParsers = new HashMap<>(); + Map> emailAttachmentParsers = new HashMap<>(); emailAttachmentParsers.put(HttpEmailAttachementParser.TYPE, new HttpEmailAttachementParser(httpClient, templateEngine)); emailAttachmentParsers.put(DataAttachmentParser.TYPE, new DataAttachmentParser()); emailAttachmentParsers.put(ReportingAttachmentParser.TYPE, @@ -326,7 +326,7 @@ ScriptTransform.TYPE, new ScriptTransformFactory(scriptService), getLicenseState()); // inputs - final Map inputFactories = new HashMap<>(); + final Map> inputFactories = new HashMap<>(); inputFactories.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry, scriptService)); inputFactories.put(SimpleInput.TYPE, new SimpleInputFactory()); inputFactories.put(HttpInput.TYPE, new HttpInputFactory(settings, httpClient, templateEngine)); @@ -389,7 +389,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) HistoryStore historyStore = new HistoryStore(bulkProcessor); // schedulers - final Set scheduleParsers = new HashSet<>(); + final Set> scheduleParsers = new HashSet<>(); scheduleParsers.add(new CronSchedule.Parser()); scheduleParsers.add(new DailySchedule.Parser()); scheduleParsers.add(new HourlySchedule.Parser()); @@ -399,10 +399,10 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) scheduleParsers.add(new YearlySchedule.Parser()); final ScheduleRegistry scheduleRegistry = new ScheduleRegistry(scheduleParsers); - TriggerEngine manualTriggerEngine = new ManualTriggerEngine(); - final TriggerEngine configuredTriggerEngine = getTriggerEngine(getClock(), scheduleRegistry); + TriggerEngine manualTriggerEngine = new ManualTriggerEngine(); + final TriggerEngine configuredTriggerEngine = getTriggerEngine(getClock(), scheduleRegistry); - final Set triggerEngines = new HashSet<>(); + final Set> triggerEngines = new HashSet<>(); triggerEngines.add(manualTriggerEngine); triggerEngines.add(configuredTriggerEngine); final TriggerService triggerService = new TriggerService(triggerEngines); @@ -436,7 +436,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) configuredTriggerEngine, triggeredWatchStore, watcherSearchTemplateService, slackService, pagerDutyService); } - protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { + protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { return new TickerScheduleTriggerEngine(settings, scheduleRegistry, clock); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java index 2adbfc675a079..7b00229337ecd 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.xpack.watcher.notification.email.EmailService; import org.elasticsearch.xpack.watcher.notification.email.HtmlSanitizer; import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser; +import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser.EmailAttachment; import org.elasticsearch.xpack.watcher.support.Variables; import java.io.IOException; @@ -35,10 +36,16 @@ public class ExecutableEmailAction extends ExecutableAction { private final EmailService emailService; private final TextTemplateEngine templateEngine; private final HtmlSanitizer htmlSanitizer; - private final Map emailAttachmentParsers; + private final Map> emailAttachmentParsers; - public ExecutableEmailAction(EmailAction action, Logger logger, EmailService emailService, TextTemplateEngine templateEngine, - HtmlSanitizer htmlSanitizer, Map emailAttachmentParsers) { + public ExecutableEmailAction( + EmailAction action, + Logger logger, + EmailService emailService, + TextTemplateEngine templateEngine, + HtmlSanitizer htmlSanitizer, + Map> emailAttachmentParsers + ) { super(action, logger); this.emailService = emailService; this.templateEngine = templateEngine; @@ -57,8 +64,10 @@ public Action.Result execute(String actionId, WatchExecutionContext ctx, Payload } if (action.getAttachments() != null && action.getAttachments().getAttachments().size() > 0) { - for (EmailAttachmentParser.EmailAttachment emailAttachment : action.getAttachments().getAttachments()) { - EmailAttachmentParser parser = emailAttachmentParsers.get(emailAttachment.type()); + for (EmailAttachment emailAttachment : action.getAttachments().getAttachments()) { + @SuppressWarnings("unchecked") + EmailAttachmentParser parser = + (EmailAttachmentParser) emailAttachmentParsers.get(emailAttachment.type()); try { Attachment attachment = parser.toAttachment(ctx, payload, emailAttachment); attachments.put(attachment.id(), attachment); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java index 99baa73f4f3d6..fc219399af001 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java @@ -55,13 +55,14 @@ public ExecutableIndexAction(IndexAction action, Logger logger, Client client, this.bulkDefaultTimeout = action.timeout != null ? action.timeout : bulkDefaultTimeout; } + @SuppressWarnings("unchecked") @Override public Action.Result execute(String actionId, WatchExecutionContext ctx, Payload payload) throws Exception { Map data = payload.data(); if (data.containsKey("_doc")) { Object doc = data.get("_doc"); if (doc instanceof Iterable) { - return indexBulk((Iterable) doc, actionId, ctx); + return indexBulk((Iterable) doc, actionId, ctx); } if (doc.getClass().isArray()) { return indexBulk(new ArrayObjectIterator.Iterable(doc), actionId, ctx); @@ -109,7 +110,7 @@ public Action.Result execute(String actionId, WatchExecutionContext ctx, Payload return new IndexAction.Result(Status.SUCCESS, new XContentSource(bytesReference, XContentType.JSON)); } - Action.Result indexBulk(Iterable list, String actionId, WatchExecutionContext ctx) throws Exception { + Action.Result indexBulk(Iterable list, String actionId, WatchExecutionContext ctx) throws Exception { if (action.docId != null) { throw illegalState("could not execute action [{}] of watch [{}]. [doc_id] cannot be used with bulk [_doc] indexing"); } @@ -125,6 +126,7 @@ Action.Result indexBulk(Iterable list, String actionId, WatchExecutionContext ct "[_data] field must either hold a Map or an List/Array of Maps", actionId, ctx.watch().id()); } + @SuppressWarnings("unchecked") Map doc = (Map) item; if (doc.containsKey(INDEX_FIELD) || doc.containsKey(TYPE_FIELD) || doc.containsKey(ID_FIELD)) { doc = mutableMap(doc); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java index 44ad396387f05..27c7ad1fa4778 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java @@ -63,6 +63,7 @@ public Action.Result execute(final String actionId, WatchExecutionContext ctx, P * Merges the defaults provided as the second parameter into the content of the first * while applying a {@link Function} on both map key and map value. */ + @SuppressWarnings("unchecked") static Map merge(final Map fields, final Map defaults, final Function fn) { if (defaults != null) { for (Map.Entry defaultEntry : defaults.entrySet()) { @@ -85,8 +86,8 @@ static Map merge(final Map fields, final Map newValues = new ArrayList<>(((List) value).size()); - for (Object v : (List) value) { + List newValues = new ArrayList<>(((List) value).size()); + for (Object v : (List) value) { if (v instanceof String) { newValues.add(fn.apply((String) v)); } else if (v instanceof Map) { diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java index ff09b6d023d63..2d49806404220 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java @@ -291,10 +291,12 @@ public static HttpRequest parse(XContentParser parser) throws IOException { pe, currentFieldName); } } else if (token == XContentParser.Token.START_OBJECT) { + @SuppressWarnings({"unchecked", "rawtypes"}) + final Map headers = (Map) WatcherUtils.flattenModel(parser.map()); if (Field.HEADERS.match(currentFieldName, parser.getDeprecationHandler())) { - builder.setHeaders((Map) WatcherUtils.flattenModel(parser.map())); + builder.setHeaders(headers); } else if (Field.PARAMS.match(currentFieldName, parser.getDeprecationHandler())) { - builder.setParams((Map) WatcherUtils.flattenModel(parser.map())); + builder.setParams(headers); } else if (Field.BODY.match(currentFieldName, parser.getDeprecationHandler())) { builder.body(parser.text()); } else { diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java index de035c12ffe0f..6476e5bcfe44f 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java @@ -22,6 +22,7 @@ public class LenientCompare { // will fail and `false` will be returned. // // may return `null` indicating v1 simply doesn't equal v2 (without any order association) + @SuppressWarnings("unchecked") public static Integer compare(Object v1, Object v2) { if (Objects.equals(v1, v2)) { return 0; diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java index b7a66cb268b19..9ca7171ad41bb 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java @@ -19,10 +19,10 @@ public class InputRegistry { - private final Map factories; + private final Map> factories; - public InputRegistry(Map factories) { - Map map = new HashMap<>(factories); + public InputRegistry(Map> factories) { + Map> map = new HashMap<>(factories); map.put(ChainInput.TYPE, new ChainInputFactory(this)); this.factories = Collections.unmodifiableMap(map); } @@ -69,7 +69,7 @@ public InputRegistry(Map factories) { return input; } - public Map factories() { + public Map> factories() { return factories; } } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java index 9b40c8f2656d4..76436f1e5e65d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java @@ -107,7 +107,7 @@ private Builder() { inputs = new ArrayList<>(); } - public Builder add(String name, Input.Builder input) { + public Builder add(String name, Input.Builder input) { inputs.add(new Tuple<>(name, input.build())); return this; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java index fcc9bd42878bd..0f416543fdb35 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java @@ -37,9 +37,11 @@ public ChainInput parseInput(String watchId, XContentParser parser) throws IOExc @Override public ExecutableChainInput createExecutable(ChainInput input) { - List> executableInputs = new ArrayList<>(); + List>> executableInputs = new ArrayList<>(); for (Tuple tuple : input.getInputs()) { - ExecutableInput executableInput = inputRegistry.factories().get(tuple.v2().type()).createExecutable(tuple.v2()); + @SuppressWarnings("unchecked") + ExecutableInput executableInput = + ((InputFactory) inputRegistry.factories().get(tuple.v2().type())).createExecutable(tuple.v2()); executableInputs.add(new Tuple<>(tuple.v1(), executableInput)); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java index 9f02c02462896..64b78f6081abf 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java @@ -24,9 +24,9 @@ public class ExecutableChainInput extends ExecutableInput { private static final Logger logger = LogManager.getLogger(ExecutableChainInput.class); - private List> inputs; + private List>> inputs; - public ExecutableChainInput(ChainInput input, List> inputs) { + public ExecutableChainInput(ChainInput input, List>> inputs) { super(input); this.inputs = inputs; } @@ -37,7 +37,7 @@ public ChainInput.Result execute(WatchExecutionContext ctx, Payload payload) { Map payloads = new HashMap<>(); try { - for (Tuple tuple : inputs) { + for (Tuple> tuple : inputs) { Input.Result result = tuple.v2().execute(ctx, new Payload.Simple(payloads)); results.add(new Tuple<>(tuple.v1(), result)); payloads.put(tuple.v1(), result.payload().data()); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java index 8a73387ace530..fb08b7c7fe471 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java @@ -14,9 +14,9 @@ public final class ExecutableTransformInput extends ExecutableInput { - private final ExecutableTransform executableTransform; + private final ExecutableTransform executableTransform; - ExecutableTransformInput(TransformInput input, ExecutableTransform executableTransform) { + ExecutableTransformInput(TransformInput input, ExecutableTransform executableTransform) { super(input); this.executableTransform = executableTransform; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java index 440964e22d4db..3be5bd0b8a72d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java @@ -49,8 +49,9 @@ public TransformInput parseInput(String watchId, XContentParser parser) throws I @Override public ExecutableTransformInput createExecutable(TransformInput input) { Transform transform = input.getTransform(); - TransformFactory factory = transformRegistry.factory(transform.type()); - ExecutableTransform executableTransform = factory.createExecutable(transform); + @SuppressWarnings("unchecked") + TransformFactory factory = (TransformFactory) transformRegistry.factory(transform.type()); + ExecutableTransform executableTransform = factory.createExecutable(transform); return new ExecutableTransformInput(input, executableTransform); } } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java index 83c4407cf2c63..099ffe80dcb59 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java @@ -30,7 +30,7 @@ public EmailAttachments(Collection attach this.attachments = attachments; } - public Collection getAttachments() { + public Collection getAttachments() { return attachments; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java index 8259125f11643..3a178673cd2a7 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java @@ -8,6 +8,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser.EmailAttachment; import java.io.IOException; import java.util.ArrayList; @@ -16,14 +17,14 @@ import java.util.Map; public class EmailAttachmentsParser { - private final Map parsers; + private final Map> parsers; - public EmailAttachmentsParser(Map parsers) { + public EmailAttachmentsParser(Map> parsers) { this.parsers = Collections.unmodifiableMap(parsers); } public EmailAttachments parse(XContentParser parser) throws IOException { - List attachments = new ArrayList<>(); + List attachments = new ArrayList<>(); String currentFieldName = null; XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -37,11 +38,11 @@ public EmailAttachments parse(XContentParser parser) throws IOException { } parser.nextToken(); - EmailAttachmentParser emailAttachmentParser = parsers.get(currentAttachmentType); + EmailAttachmentParser emailAttachmentParser = parsers.get(currentAttachmentType); if (emailAttachmentParser == null) { throw new ElasticsearchParseException("Cannot parse attachment of type [{}]", currentAttachmentType); } - EmailAttachmentParser.EmailAttachment emailAttachment = emailAttachmentParser.parse(currentFieldName, parser); + EmailAttachment emailAttachment = emailAttachmentParser.parse(currentFieldName, parser); attachments.add(emailAttachment); // one further to skip the end_object from the attachment parser.nextToken(); @@ -52,7 +53,7 @@ public EmailAttachments parse(XContentParser parser) throws IOException { return new EmailAttachments(attachments); } - public Map getParsers() { + public Map> getParsers() { return parsers; } } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java index 2e67a08e55ab6..bf62346a3bb91 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java @@ -28,6 +28,7 @@ public DynamicAttachments(String listPath, Attachment.Template attachment) { this.attachment = attachment; } + @SuppressWarnings("unchecked") public List render(TextTemplateEngine engine, Map model, SlackMessageDefaults.AttachmentDefaults defaults) { Object value = ObjectPath.eval(listPath, model); if ((value instanceof Iterable) == false) { @@ -35,7 +36,7 @@ public List render(TextTemplateEngine engine, Map mo "list, but found [" + value + "] instead"); } List attachments = new ArrayList<>(); - for (Object obj : (Iterable) value) { + for (Object obj : (Iterable) value) { if ((obj instanceof Map) == false) { throw new IllegalArgumentException("dynamic attachment could not be resolved. expected [" + listPath + "] list to contain" + " key/value pairs, but found [" + obj + "] instead"); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java index a103cb64ef451..605a4960058bb 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java @@ -50,7 +50,9 @@ ScriptTransform.Result doExecute(WatchExecutionContext ctx, Payload payload) thr Object value = transformScript.execute(); // TODO: deprecate one of these styles (returning a map or returning an opaque value below) if (value instanceof Map) { - return new ScriptTransform.Result(new Payload.Simple((Map) value)); + @SuppressWarnings("unchecked") + final Payload.Simple simplePayload = new Payload.Simple((Map) value); + return new ScriptTransform.Result(simplePayload); } Map data = new HashMap<>(); data.put("_value", value); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java index 6b77edd07e15e..b1d75d0b48479 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java @@ -30,12 +30,12 @@ public class TriggerService { private final GroupedConsumer consumer = new GroupedConsumer(); - private final Map engines; + private final Map> engines; private final Map perWatchStats = new ConcurrentHashMap<>(); - public TriggerService(Set engines) { - Map builder = new HashMap<>(); - for (TriggerEngine engine : engines) { + public TriggerService(Set> engines) { + Map> builder = new HashMap<>(); + for (TriggerEngine engine : engines) { builder.put(engine.type(), engine); engine.register(consumer); } @@ -43,14 +43,14 @@ public TriggerService(Set engines) { } public synchronized void start(Collection watches) { - for (TriggerEngine engine : engines.values()) { + for (TriggerEngine engine : engines.values()) { engine.start(watches); } watches.forEach(this::addToStats); } public synchronized void stop() { - for (TriggerEngine engine : engines.values()) { + for (TriggerEngine engine : engines.values()) { engine.stop(); } perWatchStats.clear(); @@ -157,7 +157,7 @@ public void add(Watch watch) { */ public boolean remove(String jobName) { perWatchStats.remove(jobName); - for (TriggerEngine engine : engines.values()) { + for (TriggerEngine engine : engines.values()) { if (engine.remove(jobName)) { return true; } @@ -170,7 +170,7 @@ public void register(Consumer> consumer) { } public TriggerEvent simulateEvent(String type, String jobId, Map data) { - TriggerEngine engine = engines.get(type); + TriggerEngine engine = engines.get(type); if (engine == null) { throw illegalArgument("could not simulate trigger event. unknown trigger type [{}]", type); } @@ -201,7 +201,7 @@ public Trigger parseTrigger(String jobName, XContentParser parser) throws IOExce } public Trigger parseTrigger(String jobName, String type, XContentParser parser) throws IOException { - TriggerEngine engine = engines.get(type); + TriggerEngine engine = engines.get(type); if (engine == null) { throw new ElasticsearchParseException("could not parse trigger [{}] for [{}]. unknown trigger type [{}]", type, jobName, type); } @@ -232,7 +232,7 @@ public TriggerEvent parseTriggerEvent(String watchId, String context, XContentPa } public TriggerEvent parseTriggerEvent(String watchId, String context, String type, XContentParser parser) throws IOException { - TriggerEngine engine = engines.get(type); + TriggerEngine engine = engines.get(type); if (engine == null) { throw new ElasticsearchParseException("Unknown trigger type [{}]", type); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java index d2392c7af9a38..bf44904dcd6eb 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java @@ -15,9 +15,9 @@ import java.util.Set; public class ScheduleRegistry { - private final Map parsers = new HashMap<>(); + private final Map> parsers = new HashMap<>(); - public ScheduleRegistry(Set parsers) { + public ScheduleRegistry(Set> parsers) { parsers.stream().forEach(parser -> this.parsers.put(parser.type(), parser)); } @@ -46,7 +46,7 @@ public Schedule parse(String context, XContentParser parser) throws IOException } public Schedule parse(String context, String type, XContentParser parser) throws IOException { - Schedule.Parser scheduleParser = parsers.get(type); + Schedule.Parser scheduleParser = parsers.get(type); if (scheduleParser == null) { throw new ElasticsearchParseException("could not parse schedule for [{}]. unknown schedule type [{}]", context, type); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java index b96cb6ab0e5d5..31cbc2d94e0d7 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java @@ -58,7 +58,7 @@ public class WatchParser { private final InputRegistry inputRegistry; private final CryptoService cryptoService; private final Clock clock; - private final ExecutableInput defaultInput; + private final ExecutableInput defaultInput; private final ExecutableCondition defaultCondition; private final List defaultActions; @@ -131,10 +131,10 @@ private Watch parse(String id, boolean includeStatus, boolean withSecrets, Bytes public Watch parse(String id, boolean includeStatus, WatcherXContentParser parser, long sourceSeqNo, long sourcePrimaryTerm) throws IOException { Trigger trigger = null; - ExecutableInput input = defaultInput; + ExecutableInput input = defaultInput; ExecutableCondition condition = defaultCondition; List actions = defaultActions; - ExecutableTransform transform = null; + ExecutableTransform transform = null; TimeValue throttlePeriod = null; Map metatdata = null; WatchStatus status = null; @@ -146,7 +146,7 @@ public Watch parse(String id, boolean includeStatus, WatcherXContentParser parse throw new ElasticsearchParseException("could not parse watch [{}]. null token", id); } else if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); - } else if (token == null || currentFieldName == null) { + } else if (currentFieldName == null) { throw new ElasticsearchParseException("could not parse watch [{}], unexpected token [{}]", id, token); } else if (WatchField.TRIGGER.match(currentFieldName, parser.getDeprecationHandler())) { trigger = triggerService.parseTrigger(id, parser); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherInfoTransportActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherInfoTransportActionTests.java index 7567b83cc7b5e..f7668972bf3d3 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherInfoTransportActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherInfoTransportActionTests.java @@ -90,6 +90,7 @@ public void testEnabled() { public void testUsageStats() throws Exception { doAnswer(mock -> { + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) mock.getArguments()[2]; diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java index 1a7561d738171..c220b06dcc184 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java @@ -81,7 +81,7 @@ public void testReload() { .put("xpack.watcher.enabled", true) .put("path.home", createTempDir()) .build(); - NotificationService mockService = mock(NotificationService.class); + NotificationService mockService = mock(NotificationService.class); Watcher watcher = new TestWatcher(settings, mockService); watcher.reload(settings); @@ -93,7 +93,7 @@ public void testReloadDisabled() { .put("xpack.watcher.enabled", false) .put("path.home", createTempDir()) .build(); - NotificationService mockService = mock(NotificationService.class); + NotificationService mockService = mock(NotificationService.class); Watcher watcher = new TestWatcher(settings, mockService); watcher.reload(settings); @@ -102,7 +102,7 @@ public void testReloadDisabled() { private class TestWatcher extends Watcher { - TestWatcher(Settings settings, NotificationService service) { + TestWatcher(Settings settings, NotificationService service) { super(settings); reloadableServices.add(service); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java index f024ef0e703df..82b1e86b709ce 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java @@ -114,6 +114,7 @@ void stopExecutor() { assertThat(service.validate(csBuilder.build()), is(false)); } + @SuppressWarnings({"unchecked", "rawtypes"}) public void testLoadOnlyActiveWatches() throws Exception { TriggerService triggerService = mock(TriggerService.class); TriggeredWatchStore triggeredWatchStore = mock(TriggeredWatchStore.class); @@ -160,7 +161,7 @@ void stopExecutor() { ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(refreshResponse); return null; - }).when(client).execute(eq(RefreshAction.INSTANCE), any(RefreshRequest.class), any(ActionListener.class)); + }).when(client).execute(eq(RefreshAction.INSTANCE), any(RefreshRequest.class), anyActionListener()); // empty scroll response, no further scrolling needed SearchResponseSections scrollSearchSections = new SearchResponseSections(SearchHits.empty(), null, null, false, false, null, 1); @@ -170,7 +171,7 @@ void stopExecutor() { ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(scrollSearchResponse); return null; - }).when(client).execute(eq(SearchScrollAction.INSTANCE), any(SearchScrollRequest.class), any(ActionListener.class)); + }).when(client).execute(eq(SearchScrollAction.INSTANCE), any(SearchScrollRequest.class), anyActionListener()); // one search response containing active and inactive watches int count = randomIntBetween(2, 200); @@ -202,13 +203,13 @@ void stopExecutor() { ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(searchResponse); return null; - }).when(client).execute(eq(SearchAction.INSTANCE), any(SearchRequest.class), any(ActionListener.class)); + }).when(client).execute(eq(SearchAction.INSTANCE), any(SearchRequest.class), anyActionListener()); doAnswer(invocation -> { ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(new ClearScrollResponse(true, 1)); return null; - }).when(client).execute(eq(ClearScrollAction.INSTANCE), any(ClearScrollRequest.class), any(ActionListener.class)); + }).when(client).execute(eq(ClearScrollAction.INSTANCE), any(ClearScrollRequest.class), anyActionListener()); service.start(clusterState, () -> {}); @@ -219,9 +220,10 @@ void stopExecutor() { assertThat(watches, hasSize(activeWatchCount)); } + @SuppressWarnings({"unchecked", "rawtypes"}) public void testPausingWatcherServiceAlsoPausesTriggerService() { String engineType = "foo"; - TriggerEngine triggerEngine = mock(TriggerEngine.class); + TriggerEngine triggerEngine = mock(TriggerEngine.class); when(triggerEngine.type()).thenReturn(engineType); TriggerService triggerService = new TriggerService(Collections.singleton(triggerEngine)); @@ -276,4 +278,10 @@ private static DiscoveryNode newNode() { return new DiscoveryNode("node", ESTestCase.buildNewFakeTransportAddress(), Collections.emptyMap(), DiscoveryNodeRole.roles(), Version.CURRENT); } + + + @SuppressWarnings("unchecked") + private static ActionListener anyActionListener() { + return any(ActionListener.class); + } } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java index 642493320e4ff..7065b73fccf6d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java @@ -105,7 +105,8 @@ public void testThatMultipleResultsCanBeReturned() throws Exception { final Map map = XContentHelper.convertToMap(JsonXContent.jsonXContent, json, true); assertThat(map, hasKey("foreach")); assertThat(map.get("foreach"), instanceOf(List.class)); - List> actions = (List) map.get("foreach"); + @SuppressWarnings("unchecked") + List> actions = (List>) map.get("foreach"); assertThat(actions, hasSize(3)); } } @@ -192,7 +193,8 @@ public void testDefaultLimitOfNumberOfActionsExecuted() throws Exception { final Map map = XContentHelper.convertToMap(JsonXContent.jsonXContent, json, true); assertThat(map, hasKey("foreach")); assertThat(map.get("foreach"), instanceOf(List.class)); - List> actions = (List) map.get("foreach"); + @SuppressWarnings("unchecked") + List> actions = (List>) map.get("foreach"); assertThat(actions, hasSize(100)); assertThat(map, hasKey("max_iterations")); assertThat(map.get("max_iterations"), is(100)); @@ -228,7 +230,8 @@ public void testConfiguredLimitOfNumberOfActionsExecuted() throws Exception { final Map map = XContentHelper.convertToMap(JsonXContent.jsonXContent, json, true); assertThat(map, hasKey("foreach")); assertThat(map.get("foreach"), instanceOf(List.class)); - List> actions = (List) map.get("foreach"); + @SuppressWarnings("unchecked") + List> actions = (List>) map.get("foreach"); assertThat(actions, hasSize(randomMaxIterations)); assertThat(map, hasKey("max_iterations")); assertThat(map.get("max_iterations"), is(randomMaxIterations)); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java index 2547eb2bb0e41..c4b0c9bf18dae 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java @@ -87,7 +87,7 @@ public class EmailActionTests extends ESTestCase { @Before public void addEmailAttachmentParsers() { - Map emailAttachmentParsers = new HashMap<>(); + Map> emailAttachmentParsers = new HashMap<>(); emailAttachmentParsers.put(HttpEmailAttachementParser.TYPE, new HttpEmailAttachementParser(httpClient, new MockTextTemplateEngine())); emailAttachmentParsers.put(DataAttachmentParser.TYPE, new DataAttachmentParser()); @@ -519,7 +519,7 @@ public void testThatOneFailedEmailAttachmentResultsInActionFailure() throws Exce .thenReturn(new HttpResponse(403)); // setup email attachment parsers - Map attachmentParsers = new HashMap<>(); + Map> attachmentParsers = new HashMap<>(); attachmentParsers.put(HttpEmailAttachementParser.TYPE, new HttpEmailAttachementParser(httpClient, engine)); EmailAttachmentsParser emailAttachmentsParser = new EmailAttachmentsParser(attachmentParsers); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 89a39b6275621..4411716ed02ec 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -164,11 +164,11 @@ private void expectParseFailure(XContentBuilder builder) throws Exception { expectFailure(ElasticsearchParseException.class, builder); } - private void expectFailure(Class clazz, XContentBuilder builder) throws Exception { + private void expectFailure(Class clazz, XContentBuilder builder) throws Exception { expectFailure(clazz, builder, null); } - private void expectFailure(Class clazz, XContentBuilder builder, String expectedMessage) throws Exception { + private void expectFailure(Class clazz, XContentBuilder builder, String expectedMessage) throws Exception { IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, client); XContentParser parser = createParser(builder); parser.nextToken(); @@ -189,10 +189,10 @@ public void testUsingParameterIdWithBulkOrIdFieldThrowsIllegalState() { // using doc_id with bulk fails regardless of using ID expectThrows(IllegalStateException.class, () -> { - final List idList = Arrays.asList(docWithId, MapBuilder.newMapBuilder().put("foo", "bar1").put("_id", "1").map()); + final List> idList = Arrays.asList(docWithId, MapBuilder.newMapBuilder().put("foo", "bar1").put("_id", "1").map()); final Object list = randomFrom( - new Map[] { singletonMap("foo", "bar"), singletonMap("foo", "bar1") }, + new Map[] { singletonMap("foo", "bar"), singletonMap("foo", "bar1") }, Arrays.asList(singletonMap("foo", "bar"), singletonMap("foo", "bar1")), unmodifiableSet(newHashSet(singletonMap("foo", "bar"), singletonMap("foo", "bar1"))), idList diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java index 433e3a8e8d625..3fa9753b33b9a 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java @@ -315,6 +315,7 @@ public String render(TextTemplate textTemplate, Map model) { } } + @SuppressWarnings("unchecked") public void testMerge() { Map writeableMap = new HashMap<>(); Map mergeNull = ExecutableJiraAction.merge(writeableMap, null, s -> s); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java index 4e418f7698a18..654f5c3f94cd7 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java @@ -114,6 +114,7 @@ public void testThatHeaderNamesDoNotContainDotsOnSerialization() throws Exceptio assertThat(responseMap, hasKey("headers")); assertThat(responseMap.get("headers"), instanceOf(Map.class)); + @SuppressWarnings("unchecked") Map responseHeaders = (Map) responseMap.get("headers"); assertThat(responseHeaders, not(hasKey("es.index"))); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java index 5c588416f5d6e..0d99b3ee39c5b 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java @@ -120,6 +120,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +@SuppressWarnings({"rawtypes", "unchecked"}) public class ExecutionServiceTests extends ESTestCase { private Payload payload; diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java index 26357b4607d38..28eec812dc70d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java @@ -206,6 +206,7 @@ public void testFindTriggeredWatchesGoodCase() { ClusterState cs = csBuilder.build(); doAnswer(invocation -> { + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(mockRefreshResponse(1, 1)); return null; @@ -223,6 +224,7 @@ public void testFindTriggeredWatchesGoodCase() { when(searchResponse1.getHits()).thenReturn(hits); when(searchResponse1.getScrollId()).thenReturn("_scrollId"); doAnswer(invocation -> { + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(searchResponse1); return null; @@ -240,6 +242,7 @@ public void testFindTriggeredWatchesGoodCase() { doAnswer(invocation -> { SearchScrollRequest request = (SearchScrollRequest) invocation.getArguments()[1]; + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; if (request.scrollId().equals("_scrollId")) { listener.onResponse(searchResponse2); @@ -255,6 +258,7 @@ public void testFindTriggeredWatchesGoodCase() { when(parser.parse(eq("_id"), eq(1L), any(BytesReference.class))).thenReturn(triggeredWatch); doAnswer(invocation -> { + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(new ClearScrollResponse(true, 1)); return null; @@ -378,6 +382,7 @@ public void testIndexNotFoundButInMetadata() { Watch watch = mock(Watch.class); doAnswer(invocation -> { + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onFailure(new IndexNotFoundException(TriggeredWatchStoreField.INDEX_NAME)); return null; @@ -401,7 +406,7 @@ public void testTriggeredWatchParser() throws Exception { triggeredWatch.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS); ScheduleRegistry scheduleRegistry = new ScheduleRegistry(Collections.singleton(new CronSchedule.Parser())); - TriggerEngine triggerEngine = new WatchTests.ParseOnlyScheduleTriggerEngine(scheduleRegistry, new ClockMock()); + TriggerEngine triggerEngine = new WatchTests.ParseOnlyScheduleTriggerEngine(scheduleRegistry, new ClockMock()); TriggerService triggerService = new TriggerService(singleton(triggerEngine)); TriggeredWatch.Parser parser = new TriggeredWatch.Parser(triggerService); @@ -424,6 +429,7 @@ public void testPutTriggeredWatches() throws Exception { doAnswer(invocation -> { BulkRequest bulkRequest = (BulkRequest) invocation.getArguments()[1]; + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; int size = bulkRequest.requests().size(); @@ -450,6 +456,7 @@ public void testDeleteTriggeredWatches() throws Exception { doAnswer(invocation -> { BulkRequest bulkRequest = (BulkRequest) invocation.getArguments()[0]; + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[1]; int size = bulkRequest.requests().size(); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java index 74854945b85b8..c737772cb423a 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java @@ -87,6 +87,7 @@ public void testPut() throws Exception { doAnswer(invocation -> { BulkRequest request = (BulkRequest) invocation.getArguments()[1]; + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; IndexRequest indexRequest = (IndexRequest) request.requests().get(0); @@ -146,6 +147,7 @@ public void testStoreWithHideSecrets() throws Exception { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(BulkRequest.class); doAnswer(invocation -> { + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; IndexResponse indexResponse = mock(IndexResponse.class); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java index 08bac30f13e59..497e0743a975f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java @@ -62,7 +62,7 @@ public class ChainInputTests extends ESTestCase { } */ public void testThatExecutionWorks() throws Exception { - Map factories = new HashMap<>(); + Map> factories = new HashMap<>(); factories.put("simple", new SimpleInputFactory()); // hackedy hack... @@ -97,7 +97,9 @@ public void testThatExecutionWorks() throws Exception { assertThat(payload.data().get("second"), instanceOf(Map.class)); // final payload check + @SuppressWarnings("unchecked") Map firstPayload = (Map) payload.data().get("first"); + @SuppressWarnings("unchecked") Map secondPayload = (Map) payload.data().get("second"); assertThat(firstPayload, hasEntry("foo", "bar")); assertThat(secondPayload, hasEntry("spam", "eggs")); @@ -116,7 +118,7 @@ public void testToXContent() throws Exception { is("{\"inputs\":[{\"first\":{\"simple\":{\"foo\":\"bar\"}}},{\"second\":{\"simple\":{\"spam\":\"eggs\"}}}]}")); // parsing it back as well! - Map factories = new HashMap<>(); + Map> factories = new HashMap<>(); factories.put("simple", new SimpleInputFactory()); InputRegistry inputRegistry = new InputRegistry(factories); @@ -176,7 +178,7 @@ public void testThatSerializationOfFailedInputWorks() throws Exception { } */ public void testParsingShouldBeStrictWhenClosingInputs() throws Exception { - Map factories = new HashMap<>(); + Map> factories = new HashMap<>(); factories.put("simple", new SimpleInputFactory()); InputRegistry inputRegistry = new InputRegistry(factories); @@ -205,7 +207,7 @@ public void testParsingShouldBeStrictWhenClosingInputs() throws Exception { } */ public void testParsingShouldBeStrictWhenStartingInputs() throws Exception { - Map factories = new HashMap<>(); + Map> factories = new HashMap<>(); factories.put("simple", new SimpleInputFactory()); InputRegistry inputRegistry = new InputRegistry(factories); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java index f969569596225..406a4b7d977a2 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java @@ -32,7 +32,7 @@ public void testFailedResultHandling() throws Exception { WatchExecutionContext ctx = createWatchExecutionContext(); ChainInput chainInput = new ChainInput(Arrays.asList(new Tuple<>("whatever", new SimpleInput(Payload.EMPTY)))); - Tuple tuple = new Tuple<>("whatever", new FailingExecutableInput()); + Tuple> tuple = new Tuple<>("whatever", new FailingExecutableInput()); ExecutableChainInput executableChainInput = new ExecutableChainInput(chainInput, Arrays.asList(tuple)); ChainInput.Result result = executableChainInput.execute(ctx, Payload.EMPTY); assertThat(result.status(), is(Status.SUCCESS)); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java index 39675fb039bb3..6b25dd2f2d134 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java @@ -7,11 +7,13 @@ package org.elasticsearch.xpack.watcher.input.http; import io.netty.handler.codec.http.HttpHeaders; + import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.common.xcontent.ObjectPath; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -19,9 +21,9 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; -import org.elasticsearch.common.xcontent.ObjectPath; import org.elasticsearch.xpack.core.watcher.support.xcontent.WatcherParams; import org.elasticsearch.xpack.core.watcher.watch.Payload; +import org.elasticsearch.xpack.watcher.common.http.BasicAuth; import org.elasticsearch.xpack.watcher.common.http.HttpClient; import org.elasticsearch.xpack.watcher.common.http.HttpContentType; import org.elasticsearch.xpack.watcher.common.http.HttpMethod; @@ -29,7 +31,6 @@ import org.elasticsearch.xpack.watcher.common.http.HttpRequestTemplate; import org.elasticsearch.xpack.watcher.common.http.HttpResponse; import org.elasticsearch.xpack.watcher.common.http.Scheme; -import org.elasticsearch.xpack.watcher.common.http.BasicAuth; import org.elasticsearch.xpack.watcher.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import org.elasticsearch.xpack.watcher.input.InputBuilders; @@ -57,6 +58,7 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyMapOf; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -116,7 +118,7 @@ public void testExecute() throws Exception { ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine); when(httpClient.execute(any(HttpRequest.class))).thenReturn(response); - when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body"); + when(templateEngine.render(eq(new TextTemplate("_body")), anyMapOf(String.class, Object.class))).thenReturn("_body"); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); HttpInput.Result result = input.execute(ctx, new Payload.Simple()); @@ -135,7 +137,7 @@ public void testExecuteNonJson() throws Exception { String notJson = "This is not json"; HttpResponse response = new HttpResponse(123, notJson.getBytes(StandardCharsets.UTF_8)); when(httpClient.execute(any(HttpRequest.class))).thenReturn(response); - when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body"); + when(templateEngine.render(eq(new TextTemplate("_body")), anyMapOf(String.class, Object.class))).thenReturn("_body"); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); HttpInput.Result result = input.execute(ctx, new Payload.Simple()); @@ -247,7 +249,7 @@ public void testThatHeadersAreIncludedInPayload() throws Exception { when(httpClient.execute(any(HttpRequest.class))).thenReturn(response); - when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body"); + when(templateEngine.render(eq(new TextTemplate("_body")), anyMapOf(String.class, Object.class))).thenReturn("_body"); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); HttpInput.Result result = input.execute(ctx, new Payload.Simple()); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java index 65d87b553d15c..0cec36328ddd0 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java @@ -29,11 +29,11 @@ public void testExecute() throws Exception { Map data = new HashMap<>(); data.put("foo", "bar"); data.put("baz", new ArrayList() ); - ExecutableInput staticInput = new ExecutableSimpleInput(new SimpleInput(new Payload.Simple(data))); + ExecutableInput staticInput = new ExecutableSimpleInput(new SimpleInput(new Payload.Simple(data))); Input.Result staticResult = staticInput.execute(null, new Payload.Simple()); assertEquals(staticResult.payload().data().get("foo"), "bar"); - List baz = (List)staticResult.payload().data().get("baz"); + List baz = (List) staticResult.payload().data().get("baz"); assertTrue(baz.isEmpty()); } @@ -43,23 +43,23 @@ public void testParserValid() throws Exception { data.put("baz", new ArrayList()); XContentBuilder jsonBuilder = jsonBuilder().map(data); - InputFactory parser = new SimpleInputFactory(); + InputFactory parser = new SimpleInputFactory(); XContentParser xContentParser = createParser(jsonBuilder); xContentParser.nextToken(); - ExecutableInput input = parser.parseExecutable("_id", xContentParser); + ExecutableInput input = parser.parseExecutable("_id", xContentParser); assertEquals(input.type(), SimpleInput.TYPE); Input.Result staticResult = input.execute(null, new Payload.Simple()); assertEquals(staticResult.payload().data().get("foo"), "bar"); - List baz = (List)staticResult.payload().data().get("baz"); + List baz = (List) staticResult.payload().data().get("baz"); assertTrue(baz.isEmpty()); } public void testParserInvalid() throws Exception { XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); - InputFactory parser = new SimpleInputFactory(); + InputFactory parser = new SimpleInputFactory(); XContentParser xContentParser = createParser(jsonBuilder); xContentParser.nextToken(); try { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java index 7154c0f1ed242..d4f9ca8c10c58 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java @@ -52,8 +52,8 @@ public void testExecute() { ScriptTransform scriptTransform = ScriptTransform.builder(script).build(); TransformInput transformInput = new TransformInput(scriptTransform); - ExecutableTransform executableTransform = new ExecutableScriptTransform(scriptTransform, logger, scriptService); - ExecutableInput input = new ExecutableTransformInput(transformInput, executableTransform); + ExecutableTransform executableTransform = new ExecutableScriptTransform(scriptTransform, logger, scriptService); + ExecutableInput input = new ExecutableTransformInput(transformInput, executableTransform); WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", Payload.EMPTY); Input.Result result = input.execute(ctx, new Payload.Simple()); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java index 8cb45180d4b36..b588159c6b101 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java @@ -26,7 +26,7 @@ public class DataAttachmentParserTests extends ESTestCase { public void testSerializationWorks() throws Exception { - Map attachmentParsers = new HashMap<>(); + Map> attachmentParsers = new HashMap<>(); attachmentParsers.put(DataAttachmentParser.TYPE, new DataAttachmentParser()); EmailAttachmentsParser emailAttachmentsParser = new EmailAttachmentsParser(attachmentParsers); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java index 5f28994d03197..5aa067b46d031 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.xpack.watcher.common.http.HttpRequestTemplate; import org.elasticsearch.xpack.watcher.common.http.Scheme; import org.elasticsearch.xpack.watcher.notification.email.Attachment; +import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser.EmailAttachment; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -39,7 +40,7 @@ public class EmailAttachmentParsersTests extends ESTestCase { private WatchExecutionContext ctx = mock(WatchExecutionContext.class); public void testThatCustomParsersCanBeRegistered() throws Exception { - Map parsers = new HashMap<>(); + Map> parsers = new HashMap<>(); parsers.put("test", new TestEmailAttachmentParser()); EmailAttachmentsParser parser = new EmailAttachmentsParser(parsers); @@ -62,15 +63,17 @@ public void testThatCustomParsersCanBeRegistered() throws Exception { EmailAttachments attachments = parser.parse(xContentParser); assertThat(attachments.getAttachments(), hasSize(2)); - List emailAttachments = new ArrayList<>(attachments.getAttachments()); - EmailAttachmentParser.EmailAttachment emailAttachment = emailAttachments.get(0); + List emailAttachments = new ArrayList<>(attachments.getAttachments()); + EmailAttachment emailAttachment = emailAttachments.get(0); assertThat(emailAttachment, instanceOf(TestEmailAttachment.class)); - Attachment attachment = parsers.get("test").toAttachment(ctx, new Payload.Simple(), emailAttachment); + @SuppressWarnings("unchecked") + EmailAttachmentParser testParser = (EmailAttachmentParser) parsers.get("test"); + Attachment attachment = testParser.toAttachment(ctx, new Payload.Simple(), emailAttachment); assertThat(attachment.name(), is("my-id")); assertThat(attachment.contentType(), is("personalContentType")); - assertThat(parsers.get("test").toAttachment(ctx, new Payload.Simple(), emailAttachments.get(1)).id(), is("my-other-id")); + assertThat(testParser.toAttachment(ctx, new Payload.Simple(), emailAttachments.get(1)).id(), is("my-other-id")); } public void testThatUnknownParserThrowsException() throws IOException { @@ -90,7 +93,7 @@ public void testThatUnknownParserThrowsException() throws IOException { } public void testThatToXContentSerializationWorks() throws Exception { - List attachments = new ArrayList<>(); + List attachments = new ArrayList<>(); attachments.add(new DataAttachment("my-name.json", org.elasticsearch.xpack.watcher.notification.email.DataAttachment.JSON)); HttpRequestTemplate requestTemplate = HttpRequestTemplate.builder("localhost", 80).scheme(Scheme.HTTP).path("/").build(); @@ -150,7 +153,7 @@ public Attachment toAttachment(WatchExecutionContext ctx, Payload payload, TestE } } - public static class TestEmailAttachment implements EmailAttachmentParser.EmailAttachment { + public static class TestEmailAttachment implements EmailAttachment { private final String value; private final String id; diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java index 155d0352f000e..9ffa99d78a749 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java @@ -20,6 +20,7 @@ import org.elasticsearch.xpack.watcher.common.http.HttpRequest; import org.elasticsearch.xpack.watcher.common.http.HttpRequestTemplate; import org.elasticsearch.xpack.watcher.common.http.HttpResponse; +import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser.EmailAttachment; import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine; import org.junit.Before; @@ -44,7 +45,7 @@ public class HttpEmailAttachementParserTests extends ESTestCase { private HttpClient httpClient; private EmailAttachmentsParser emailAttachmentsParser; - private Map attachmentParsers; + private Map> attachmentParsers; @Before public void init() throws Exception { @@ -89,7 +90,7 @@ public void testSerializationWorks() throws Exception { assertThat(emailAttachments.getAttachments(), hasSize(1)); XContentBuilder toXcontentBuilder = jsonBuilder().startObject(); - List attachments = new ArrayList<>(emailAttachments.getAttachments()); + List attachments = new ArrayList<>(emailAttachments.getAttachments()); attachments.get(0).toXContent(toXcontentBuilder, ToXContent.EMPTY_PARAMS); toXcontentBuilder.endObject(); assertThat(Strings.toString(toXcontentBuilder), is(Strings.toString(builder))); @@ -106,7 +107,12 @@ public void testNonOkHttpCodeThrowsException() throws Exception { WatchExecutionContext ctx = createWatchExecutionContext(); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> attachmentParsers.get(HttpEmailAttachementParser.TYPE).toAttachment(ctx, new Payload.Simple(), attachment)); + () -> { + @SuppressWarnings("unchecked") + EmailAttachmentParser parser = + (EmailAttachmentParser) attachmentParsers.get(HttpEmailAttachementParser.TYPE); + parser.toAttachment(ctx, new Payload.Simple(), attachment); + }); assertThat(exception.getMessage(), is("Watch[watch1] attachment[someid] HTTP error status host[localhost], port[80], " + "method[GET], path[foo], status[403]")); } @@ -120,7 +126,12 @@ public void testEmptyResponseThrowsException() throws Exception { WatchExecutionContext ctx = createWatchExecutionContext(); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> attachmentParsers.get(HttpEmailAttachementParser.TYPE).toAttachment(ctx, new Payload.Simple(), attachment)); + () -> { + @SuppressWarnings("unchecked") + EmailAttachmentParser parser = + (EmailAttachmentParser) attachmentParsers.get(HttpEmailAttachementParser.TYPE); + parser.toAttachment(ctx, new Payload.Simple(), attachment); + }); assertThat(exception.getMessage(), is("Watch[watch1] attachment[someid] HTTP empty response body host[localhost], port[80], " + "method[GET], path[foo], status[200]")); } @@ -133,7 +144,12 @@ public void testHttpClientThrowsException() throws Exception { WatchExecutionContext ctx = createWatchExecutionContext(); IOException exception = expectThrows(IOException.class, - () -> attachmentParsers.get(HttpEmailAttachementParser.TYPE).toAttachment(ctx, new Payload.Simple(), attachment)); + () -> { + @SuppressWarnings("unchecked") + EmailAttachmentParser parser = + (EmailAttachmentParser) attachmentParsers.get(HttpEmailAttachementParser.TYPE); + parser.toAttachment(ctx, new Payload.Simple(), attachment); + }); assertThat(exception.getMessage(), is("whatever")); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java index 6362a0f452ab8..78dd1f142deee 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.xpack.watcher.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import org.elasticsearch.xpack.watcher.notification.email.Attachment; +import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser.EmailAttachment; import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine; import org.junit.Before; import org.mockito.ArgumentCaptor; @@ -72,7 +73,7 @@ public class ReportingAttachmentParserTests extends ESTestCase { private HttpClient httpClient; - private Map attachmentParsers = new HashMap<>(); + private Map> attachmentParsers = new HashMap<>(); private EmailAttachmentsParser emailAttachmentsParser; private ReportingAttachmentParser reportingAttachmentParser; private MockTextTemplateEngine templateEngine = new MockTextTemplateEngine(); @@ -142,7 +143,7 @@ public void testSerializationWorks() throws Exception { assertThat(emailAttachments.getAttachments(), hasSize(1)); XContentBuilder toXcontentBuilder = jsonBuilder().startObject(); - List attachments = new ArrayList<>(emailAttachments.getAttachments()); + List attachments = new ArrayList<>(emailAttachments.getAttachments()); WatcherParams watcherParams = WatcherParams.builder().hideSecrets(isPasswordEncrypted).build(); attachments.get(0).toXContent(toXcontentBuilder, watcherParams); toXcontentBuilder.endObject(); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java index cb9fcd6594d5f..7be5577a6a299 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java @@ -177,6 +177,7 @@ private void assertCustomUrl(String urlSettings, String expectedPath) throws IOE assertThat(request.path(), is(expectedPath)); } + @SuppressWarnings("unchecked") private void addAccountSettings(String name, Settings.Builder builder) { final MockSecureSettings secureSettings = new MockSecureSettings(); secureSettings.setString("xpack.notification.jira.account." + name + "." + JiraAccount.SECURE_URL_SETTING.getKey(), diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventTests.java index 6dab3081935c8..a37a05d317859 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventTests.java @@ -96,7 +96,7 @@ public void testPagerDutyXContent() throws IOException { } List actualLinks = new ArrayList<>(); - List> linkMap = (List>) objectPath.evaluate(IncidentEvent.Fields.LINKS.getPreferredName()); + List> linkMap = objectPath.evaluate(IncidentEvent.Fields.LINKS.getPreferredName()); if (linkMap != null) { for (Map iecValue : linkMap) { actualLinks.add(IncidentEventContext.link(iecValue.get("href"), iecValue.get("text"))); @@ -104,7 +104,7 @@ public void testPagerDutyXContent() throws IOException { } List actualImages = new ArrayList<>(); - List> imgMap = (List>) objectPath.evaluate(IncidentEvent.Fields.IMAGES.getPreferredName()); + List> imgMap = objectPath.evaluate(IncidentEvent.Fields.IMAGES.getPreferredName()); if (imgMap != null) { for (Map iecValue : imgMap) { actualImages.add(IncidentEventContext.image(iecValue.get("src"), iecValue.get("href"), iecValue.get("alt"))); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java index b62f12799da7f..0b7d9d23e9582 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java @@ -134,6 +134,7 @@ public void testArraysAreNotCutOff() throws Exception { assertThat(filteredData.get("buckets"), instanceOf(List.class)); // both buckets have to include the following keys + @SuppressWarnings("unchecked") List> buckets = (List>) filteredData.get("buckets"); assertThat(buckets, hasSize(2)); assertThat(buckets.get(0).keySet(), containsInAnyOrder("foo")); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index edc540965fe6b..5170099171faa 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -83,6 +83,7 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { private ThreadPool threadPool; private Client client; + @SuppressWarnings("unchecked") @Before public void createRegistryAndClient() { threadPool = mock(ThreadPool.class); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java index f1520e3e47734..546ecb6d6783f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java @@ -59,7 +59,7 @@ protected Clock getClock() { } @Override - protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry){ + protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry){ return new ScheduleTriggerEngineMock(scheduleRegistry, clock); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java index 1771fc9172518..8d4adb1f1d1b1 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java @@ -211,7 +211,7 @@ public BenchmarkWatcher(Settings settings) { } @Override - protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { + protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { return new ScheduleTriggerEngineMock(scheduleRegistry, clock); } } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java index 98b35f1edf6f7..60b8ce8d65b23 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java @@ -87,6 +87,7 @@ public void setup() { when(client.threadPool()).thenReturn(threadPool); } + @SuppressWarnings("unchecked") public void testExecute() throws Exception { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(SearchRequest.class); PlainActionFuture searchFuture = PlainActionFuture.newFuture(); @@ -95,6 +96,7 @@ public void testExecute() throws Exception { searchFuture.onResponse(searchResponse); when(client.search(requestCaptor.capture())).thenReturn(searchFuture); + @SuppressWarnings("rawtypes") ArgumentCaptor headersCaptor = ArgumentCaptor.forClass(Map.class); when(client.filterWithHeader(headersCaptor.capture())).thenReturn(client); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java index 08e19b61804e6..969a5050e77d7 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java @@ -53,29 +53,29 @@ public void testExecute() throws Exception { new NamedExecutableTransform("name3")); WatchExecutionContext ctx = mock(WatchExecutionContext.class); - Payload payload = new Payload.Simple(new HashMap()); + Payload payload = new Payload.Simple(new HashMap<>()); ChainTransform.Result result = executable.execute(ctx, payload); assertThat(result.status(), is(Transform.Result.Status.SUCCESS)); assertThat(result.results(), hasSize(3)); assertThat(result.results().get(0), instanceOf(NamedExecutableTransform.Result.class)); assertThat(result.results().get(0).status(), is(Transform.Result.Status.SUCCESS)); - assertThat((List) result.results().get(0).payload().data().get("names"), hasSize(1)); - assertThat((List) result.results().get(0).payload().data().get("names"), contains("name1")); + assertThat(getNames(result.results().get(0).payload()), hasSize(1)); + assertThat(getNames(result.results().get(0).payload()), contains("name1")); assertThat(result.results().get(1), instanceOf(NamedExecutableTransform.Result.class)); assertThat(result.results().get(1).status(), is(Transform.Result.Status.SUCCESS)); - assertThat((List) result.results().get(1).payload().data().get("names"), hasSize(2)); - assertThat((List) result.results().get(1).payload().data().get("names"), contains("name1", "name2")); + assertThat(getNames(result.results().get(1).payload()), hasSize(2)); + assertThat(getNames(result.results().get(1).payload()), contains("name1", "name2")); assertThat(result.results().get(2), instanceOf(NamedExecutableTransform.Result.class)); assertThat(result.results().get(2).status(), is(Transform.Result.Status.SUCCESS)); - assertThat((List) result.results().get(2).payload().data().get("names"), hasSize(3)); - assertThat((List) result.results().get(2).payload().data().get("names"), contains("name1", "name2", "name3")); + assertThat(getNames(result.results().get(2).payload()), hasSize(3)); + assertThat(getNames(result.results().get(2).payload()), contains("name1", "name2", "name3")); Map data = result.payload().data(); assertThat(data, notNullValue()); assertThat(data, hasKey("names")); assertThat(data.get("names"), instanceOf(List.class)); - List names = (List) data.get("names"); + List names = getNames(result.payload()); assertThat(names, hasSize(3)); assertThat(names, contains("name1", "name2", "name3")); } @@ -92,7 +92,7 @@ public void testExecuteFailure() throws Exception { new FailingExecutableTransform(logger)); WatchExecutionContext ctx = mock(WatchExecutionContext.class); - Payload payload = new Payload.Simple(new HashMap()); + Payload payload = new Payload.Simple(new HashMap<>()); ChainTransform.Result result = executable.execute(ctx, payload); assertThat(result.status(), is(Transform.Result.Status.FAILURE)); @@ -100,12 +100,12 @@ public void testExecuteFailure() throws Exception { assertThat(result.results(), hasSize(3)); assertThat(result.results().get(0), instanceOf(NamedExecutableTransform.Result.class)); assertThat(result.results().get(0).status(), is(Transform.Result.Status.SUCCESS)); - assertThat((List) result.results().get(0).payload().data().get("names"), hasSize(1)); - assertThat((List) result.results().get(0).payload().data().get("names"), contains("name1")); + assertThat(getNames(result.results().get(0).payload()), hasSize(1)); + assertThat(getNames(result.results().get(0).payload()), contains("name1")); assertThat(result.results().get(1), instanceOf(NamedExecutableTransform.Result.class)); assertThat(result.results().get(1).status(), is(Transform.Result.Status.SUCCESS)); - assertThat((List) result.results().get(1).payload().data().get("names"), hasSize(2)); - assertThat((List) result.results().get(1).payload().data().get("names"), contains("name1", "name2")); + assertThat(getNames(result.results().get(1).payload()), hasSize(2)); + assertThat(getNames(result.results().get(1).payload()), contains("name1", "name2")); assertThat(result.results().get(2), instanceOf(FailingExecutableTransform.Result.class)); assertThat(result.results().get(2).status(), is(Transform.Result.Status.FAILURE)); assertThat(result.results().get(2).reason(), containsString("_error")); @@ -136,6 +136,11 @@ public void testParser() throws Exception { } } + @SuppressWarnings("unchecked") + private static List getNames(Payload payload) { + return (List) payload.data().get("names"); + } + private static class NamedExecutableTransform extends ExecutableTransform { private static final String TYPE = "named"; @@ -150,7 +155,7 @@ private static class NamedExecutableTransform extends ExecutableTransform names = (List) payload.data().get("names"); + List names = getNames(payload); if (names == null) { names = new ArrayList<>(); } else { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java index 692138385b854..f33d03cb18c2e 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java @@ -197,7 +197,7 @@ public static ScriptService createScriptService() throws Exception { Settings settings = Settings.builder() .put("path.home", createTempDir()) .build(); - Map contexts = new HashMap<>(ScriptModule.CORE_CONTEXTS); + Map> contexts = new HashMap<>(ScriptModule.CORE_CONTEXTS); contexts.put(WatcherTransformScript.CONTEXT.name, WatcherTransformScript.CONTEXT); contexts.put(Watcher.SCRIPT_TEMPLATE_CONTEXT.name, Watcher.SCRIPT_TEMPLATE_CONTEXT); return new ScriptService(settings, Collections.emptyMap(), Collections.emptyMap()); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportAckWatchActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportAckWatchActionTests.java index c52016746ec96..04ddeec0fff41 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportAckWatchActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportAckWatchActionTests.java @@ -48,6 +48,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +@SuppressWarnings({"unchecked", "rawtypes"}) public class TransportAckWatchActionTests extends ESTestCase { private TransportAckWatchAction action; diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportPutWatchActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportPutWatchActionTests.java index b100836b1ded2..c3ae338e6f9be 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportPutWatchActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/TransportPutWatchActionTests.java @@ -68,6 +68,7 @@ public void setupAction() throws Exception { // mock an index response that calls the listener doAnswer(invocation -> { IndexRequest request = (IndexRequest) invocation.getArguments()[1]; + @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocation.getArguments()[2]; ShardId shardId = new ShardId(new Index(Watch.INDEX, "uuid"), 0); @@ -80,6 +81,7 @@ public void setupAction() throws Exception { new ClockHolder(new ClockMock()), TestUtils.newTestLicenseState(), parser, client); } + @SuppressWarnings({"unchecked", "rawtypes"}) public void testHeadersAreFilteredWhenPuttingWatches() throws Exception { // set up threadcontext with some arbitrary info String headerName = randomFrom(ClientHelper.SECURITY_HEADER_FILTERS); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java index d2e5716f4e7b7..7884fb158a03c 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java @@ -38,7 +38,7 @@ public class TriggerServiceTests extends ESTestCase { @Before public void setupTriggerService() { - TriggerEngine triggerEngine = mock(TriggerEngine.class); + TriggerEngine triggerEngine = mock(TriggerEngine.class); when(triggerEngine.type()).thenReturn(ENGINE_TYPE); service = new TriggerService(Collections.singleton(triggerEngine)); @@ -144,6 +144,7 @@ private Watch createWatch(String id) { return watch; } + @SuppressWarnings({"rawtypes", "unchecked"}) private void setInput(Watch watch) { ExecutableInput noneInput = new ExecutableNoneInput(); when(watch.input()).thenReturn(noneInput); @@ -160,6 +161,7 @@ private void setCondition(Watch watch, String type) { when(watch.condition()).thenReturn(condition); } + @SuppressWarnings({"rawtypes", "unchecked"}) private void addAction(Watch watch, String type, String condition, String transform) { List actions = watch.actions(); ArrayList newActions = new ArrayList<>(actions); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java index 8c4fe245b6f5f..b2f542552e896 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java @@ -27,7 +27,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase { @Before public void init() throws Exception { - Set parsers = new HashSet<>(); + Set> parsers = new HashSet<>(); parsers.add(new IntervalSchedule.Parser()); parsers.add(new CronSchedule.Parser()); parsers.add(new HourlySchedule.Parser()); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java index 8115029166a61..e4d512e08909b 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java @@ -73,6 +73,7 @@ public void testHeadersToXContent() throws Exception { Map fields = parser.map(); assertThat(fields, hasKey(WatchStatus.Field.HEADERS.getPreferredName())); assertThat(fields.get(WatchStatus.Field.HEADERS.getPreferredName()), instanceOf(Map.class)); + @SuppressWarnings("unchecked") Map extractedHeaders = (Map) fields.get(WatchStatus.Field.HEADERS.getPreferredName()); assertThat(extractedHeaders, is(headers)); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java index e7ae993c8f086..f81607e2cf558 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java @@ -183,16 +183,16 @@ public void testParserSelfGenerated() throws Exception { Schedule schedule = randomSchedule(); Trigger trigger = new ScheduleTrigger(schedule); ScheduleRegistry scheduleRegistry = registry(schedule); - TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, clock); + TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, clock); TriggerService triggerService = new TriggerService(singleton(triggerEngine)); - ExecutableInput input = randomInput(); + ExecutableInput input = randomInput(); InputRegistry inputRegistry = registry(input.type()); ExecutableCondition condition = AlwaysConditionTests.randomCondition(scriptService); ConditionRegistry conditionRegistry = conditionRegistry(); - ExecutableTransform transform = randomTransform(); + ExecutableTransform transform = randomTransform(); List actions = randomActions(); ActionRegistry actionRegistry = registry(actions, conditionRegistry, transformRegistry); @@ -272,10 +272,10 @@ public Trigger parseTrigger(String jobName, XContentParser parser) throws IOExce public void testParserBadActions() throws Exception { ClockMock clock = ClockMock.frozen(); ScheduleRegistry scheduleRegistry = registry(randomSchedule()); - TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, clock); + TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, clock); TriggerService triggerService = new TriggerService(singleton(triggerEngine)); ConditionRegistry conditionRegistry = conditionRegistry(); - ExecutableInput input = randomInput(); + ExecutableInput input = randomInput(); InputRegistry inputRegistry = registry(input.type()); TransformRegistry transformRegistry = transformRegistry(); @@ -300,7 +300,7 @@ public void testParserBadActions() throws Exception { public void testParserDefaults() throws Exception { Schedule schedule = randomSchedule(); ScheduleRegistry scheduleRegistry = registry(schedule); - TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, Clock.systemUTC()); + TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, Clock.systemUTC()); TriggerService triggerService = new TriggerService(singleton(triggerEngine)); ConditionRegistry conditionRegistry = conditionRegistry(); @@ -328,7 +328,7 @@ public void testParserDefaults() throws Exception { public void testParseWatch_verifyScriptLangDefault() throws Exception { ScheduleRegistry scheduleRegistry = registry(new IntervalSchedule(new IntervalSchedule.Interval(1, IntervalSchedule.Interval.Unit.SECONDS))); - TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, Clock.systemUTC()); + TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, Clock.systemUTC()); TriggerService triggerService = new TriggerService(singleton(triggerEngine)); ConditionRegistry conditionRegistry = conditionRegistry(); @@ -447,7 +447,7 @@ private WatchParser createWatchparser() throws Exception { ScheduleRegistry scheduleRegistry = registry(new IntervalSchedule(new IntervalSchedule.Interval(1, IntervalSchedule.Interval.Unit.SECONDS))); - TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, Clock.systemUTC()); + TriggerEngine triggerEngine = new ParseOnlyScheduleTriggerEngine(scheduleRegistry, Clock.systemUTC()); TriggerService triggerService = new TriggerService(singleton(triggerEngine)); ConditionRegistry conditionRegistry = conditionRegistry(); @@ -480,7 +480,7 @@ private static Schedule randomSchedule() { } private static ScheduleRegistry registry(Schedule schedule) { - Set parsers = new HashSet<>(); + Set> parsers = new HashSet<>(); switch (schedule.type()) { case CronSchedule.TYPE: parsers.add(new CronSchedule.Parser()); @@ -508,7 +508,7 @@ private static ScheduleRegistry registry(Schedule schedule) { } } - private ExecutableInput randomInput() { + private ExecutableInput randomInput() { String type = randomFrom(SearchInput.TYPE, SimpleInput.TYPE); switch (type) { case SearchInput.TYPE: @@ -523,7 +523,7 @@ private ExecutableInput randomInput() { } private InputRegistry registry(String inputType) { - Map parsers = new HashMap<>(); + Map> parsers = new HashMap<>(); switch (inputType) { case SearchInput.TYPE: parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry(), scriptService)); @@ -546,7 +546,7 @@ private ConditionRegistry conditionRegistry() { return new ConditionRegistry(parsers, ClockMock.frozen()); } - private ExecutableTransform randomTransform() { + private ExecutableTransform randomTransform() { String type = randomFrom(ScriptTransform.TYPE, SearchTransform.TYPE, ChainTransform.TYPE); TimeValue timeout = randomBoolean() ? timeValueSeconds(between(1, 10000)) : null; ZoneOffset timeZone = randomBoolean() ? ZoneOffset.UTC : null; @@ -563,7 +563,7 @@ private ExecutableTransform randomTransform() { ScriptTransform scriptTransform = new ScriptTransform(mockScript("_script")); ChainTransform chainTransform = new ChainTransform(Arrays.asList(searchTransform, scriptTransform)); - return new ExecutableChainTransform(chainTransform, logger, Arrays.asList( + return new ExecutableChainTransform(chainTransform, logger, Arrays.asList( new ExecutableSearchTransform(new SearchTransform( templateRequest(searchSource()), timeout, timeZone), logger, client, searchTemplateService, TimeValue.timeValueMinutes(1)),