Skip to content

Commit 6fde9e5

Browse files
authored
Watcher: Remove unused hipchat render method (elastic#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.
1 parent e1206a6 commit 6fde9e5

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
import org.elasticsearch.common.xcontent.XContentBuilder;
1414
import org.elasticsearch.common.xcontent.XContentParser;
1515
import org.elasticsearch.xpack.watcher.common.text.TextTemplate;
16-
import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine;
1716

1817
import java.io.IOException;
1918
import java.util.ArrayList;
2019
import java.util.Arrays;
2120
import java.util.List;
2221
import java.util.Locale;
23-
import java.util.Map;
2422
import java.util.Objects;
2523

2624
public class HipChatMessage implements ToXContentObject {
@@ -181,26 +179,6 @@ public int hashCode() {
181179
return Objects.hash(body, rooms, users, from, format, color, notify);
182180
}
183181

184-
public HipChatMessage render(TextTemplateEngine engine, Map<String, Object> model) {
185-
String body = engine.render(this.body, model);
186-
String[] rooms = null;
187-
if (this.rooms != null) {
188-
rooms = new String[this.rooms.length];
189-
for (int i = 0; i < this.rooms.length; i++) {
190-
rooms[i] = engine.render(this.rooms[i], model);
191-
}
192-
}
193-
String[] users = null;
194-
if (this.users != null) {
195-
users = new String[this.users.length];
196-
for (int i = 0; i < this.users.length; i++) {
197-
users[i] = engine.render(this.users[i], model);
198-
}
199-
}
200-
Color color = this.color == null ? null : Color.resolve(engine.render(this.color, model), null);
201-
return new HipChatMessage(body, rooms, users, from, format, color, notify);
202-
}
203-
204182
@Override
205183
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
206184
builder.startObject();

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@
1212
import org.elasticsearch.xpack.watcher.common.http.HttpProxy;
1313
import org.elasticsearch.xpack.watcher.common.http.HttpRequest;
1414
import org.elasticsearch.xpack.watcher.common.http.HttpResponse;
15-
import org.elasticsearch.xpack.watcher.common.text.TextTemplate;
16-
import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine;
1715
import org.junit.Before;
1816
import org.mockito.ArgumentCaptor;
1917

20-
import java.util.HashMap;
2118
import java.util.HashSet;
2219

2320
import static org.hamcrest.Matchers.is;
@@ -40,11 +37,7 @@ public void testProxy() throws Exception {
4037
new HashSet<>(HipChatService.getSettings())));
4138
HipChatAccount account = service.getAccount("account1");
4239

43-
HipChatMessage.Template template = new HipChatMessage.Template.Builder(new TextTemplate("foo"))
44-
.addRooms(new TextTemplate("room"))
45-
.setFrom("from")
46-
.build();
47-
HipChatMessage hipChatMessage = template.render(new MockTextTemplateEngine(), new HashMap<>());
40+
HipChatMessage hipChatMessage = new HipChatMessage("body", new String[]{"rooms"}, null, "from", null, null, null);
4841

4942
ArgumentCaptor<HttpRequest> argumentCaptor = ArgumentCaptor.forClass(HttpRequest.class);
5043
when(httpClient.execute(argumentCaptor.capture())).thenReturn(new HttpResponse(200));

0 commit comments

Comments
 (0)