From a5ec145851818ef2decba7460a51df24dc614e80 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 14 Aug 2018 11:07:58 -0500 Subject: [PATCH] Watcher: Remove unused hipchat render method (#32211) The HipChatMessage#render is no longer used, and instead the HipChatAccount#render is used in the ExecutableHipChatAction. Only a test that validated the HttpProxy used this render method still. This commit cleans it up. --- .../notification/hipchat/HipChatMessage.java | 22 ------------------- .../hipchat/HipChatAccountsTests.java | 9 +------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java index ae08bb85e9dfd..10eaba535edf1 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java @@ -13,14 +13,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.watcher.common.text.TextTemplate; -import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Objects; public class HipChatMessage implements ToXContentObject { @@ -181,26 +179,6 @@ public int hashCode() { return Objects.hash(body, rooms, users, from, format, color, notify); } - public HipChatMessage render(TextTemplateEngine engine, Map model) { - String body = engine.render(this.body, model); - String[] rooms = null; - if (this.rooms != null) { - rooms = new String[this.rooms.length]; - for (int i = 0; i < this.rooms.length; i++) { - rooms[i] = engine.render(this.rooms[i], model); - } - } - String[] users = null; - if (this.users != null) { - users = new String[this.users.length]; - for (int i = 0; i < this.users.length; i++) { - users[i] = engine.render(this.users[i], model); - } - } - Color color = this.color == null ? null : Color.resolve(engine.render(this.color, model), null); - return new HipChatMessage(body, rooms, users, from, format, color, notify); - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java index b793bf9202382..795f5aaacc7c9 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java @@ -12,12 +12,9 @@ import org.elasticsearch.xpack.watcher.common.http.HttpProxy; import org.elasticsearch.xpack.watcher.common.http.HttpRequest; import org.elasticsearch.xpack.watcher.common.http.HttpResponse; -import org.elasticsearch.xpack.watcher.common.text.TextTemplate; -import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine; import org.junit.Before; import org.mockito.ArgumentCaptor; -import java.util.HashMap; import java.util.HashSet; import static org.hamcrest.Matchers.is; @@ -40,11 +37,7 @@ public void testProxy() throws Exception { new HashSet<>(HipChatService.getSettings()))); HipChatAccount account = service.getAccount("account1"); - HipChatMessage.Template template = new HipChatMessage.Template.Builder(new TextTemplate("foo")) - .addRooms(new TextTemplate("room")) - .setFrom("from") - .build(); - HipChatMessage hipChatMessage = template.render(new MockTextTemplateEngine(), new HashMap<>()); + HipChatMessage hipChatMessage = new HipChatMessage("body", new String[]{"rooms"}, null, "from", null, null, null); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(HttpRequest.class); when(httpClient.execute(argumentCaptor.capture())).thenReturn(new HttpResponse(200));