Skip to content

Commit 76ae97a

Browse files
committed
Remove all these unnecessary throws declarations
1 parent 360ce4f commit 76ae97a

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CommunityIdProcessorTests.java

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class CommunityIdProcessorTests extends ESTestCase {
4141
private Map<String, Object> event;
4242

4343
@Before
44-
public void setup() throws Exception {
44+
public void setup() {
4545
event = buildEvent();
4646
}
4747

@@ -61,31 +61,31 @@ private Map<String, Object> buildEvent() {
6161
return event;
6262
}
6363

64-
public void testBeatsValid() throws Exception {
64+
public void testBeatsValid() {
6565
testCommunityIdProcessor(event, "1:LQU9qZlK+B5F3KDmev6m5PMibrg=");
6666
}
6767

68-
public void testBeatsSeed() throws Exception {
68+
public void testBeatsSeed() {
6969
testCommunityIdProcessor(event, 123, "1:hTSGlFQnR58UCk+NfKRZzA32dPg=");
7070
}
7171

72-
public void testBeatsInvalidSourceIp() throws Exception {
72+
public void testBeatsInvalidSourceIp() {
7373
@SuppressWarnings("unchecked")
7474
var source = (Map<String, Object>) event.get("source");
7575
source.put("ip", 2162716280L);
7676
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testCommunityIdProcessor(event, null));
7777
assertThat(e.getMessage(), containsString("field [source.ip] of type [java.lang.Long] cannot be cast to [java.lang.String]"));
7878
}
7979

80-
public void testBeatsInvalidSourcePort() throws Exception {
80+
public void testBeatsInvalidSourcePort() {
8181
@SuppressWarnings("unchecked")
8282
var source = (Map<String, Object>) event.get("source");
8383
source.put("port", 0);
8484
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testCommunityIdProcessor(event, null));
8585
assertThat(e.getMessage(), containsString("invalid source port"));
8686
}
8787

88-
public void testBeatsInvalidDestinationIp() throws Exception {
88+
public void testBeatsInvalidDestinationIp() {
8989
@SuppressWarnings("unchecked")
9090
var destination = (Map<String, Object>) event.get("destination");
9191
String invalidIp = "308.111.1.2.3";
@@ -94,7 +94,7 @@ public void testBeatsInvalidDestinationIp() throws Exception {
9494
assertThat(e.getMessage(), containsString("'" + invalidIp + "' is not an IP string literal"));
9595
}
9696

97-
public void testBeatsInvalidDestinationPort() throws Exception {
97+
public void testBeatsInvalidDestinationPort() {
9898
@SuppressWarnings("unchecked")
9999
var destination = (Map<String, Object>) event.get("destination");
100100
destination.put("port", null);
@@ -103,15 +103,15 @@ public void testBeatsInvalidDestinationPort() throws Exception {
103103
assertThat(e.getMessage(), containsString("invalid destination port [null]"));
104104
}
105105

106-
public void testBeatsUnknownProtocol() throws Exception {
106+
public void testBeatsUnknownProtocol() {
107107
@SuppressWarnings("unchecked")
108108
var network = (Map<String, Object>) event.get("network");
109109
network.put("transport", "xyz");
110110
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testCommunityIdProcessor(event, null));
111111
assertThat(e.getMessage(), containsString("could not convert string [xyz] to transport protocol"));
112112
}
113113

114-
public void testBeatsIcmp() throws Exception {
114+
public void testBeatsIcmp() {
115115
@SuppressWarnings("unchecked")
116116
var network = (Map<String, Object>) event.get("network");
117117
network.put("transport", "icmp");
@@ -122,14 +122,14 @@ public void testBeatsIcmp() throws Exception {
122122
testCommunityIdProcessor(event, "1:KF3iG9XD24nhlSy4r1TcYIr5mfE=");
123123
}
124124

125-
public void testBeatsIcmpWithoutTypeOrCode() throws Exception {
125+
public void testBeatsIcmpWithoutTypeOrCode() {
126126
@SuppressWarnings("unchecked")
127127
var network = (Map<String, Object>) event.get("network");
128128
network.put("transport", "icmp");
129129
testCommunityIdProcessor(event, "1:PAE85ZfR4SbNXl5URZwWYyDehwU=");
130130
}
131131

132-
public void testBeatsIgmp() throws Exception {
132+
public void testBeatsIgmp() {
133133
@SuppressWarnings("unchecked")
134134
var network = (Map<String, Object>) event.get("network");
135135
network.put("transport", "igmp");
@@ -142,7 +142,7 @@ public void testBeatsIgmp() throws Exception {
142142
testCommunityIdProcessor(event, "1:D3t8Q1aFA6Ev0A/AO4i9PnU3AeI=");
143143
}
144144

145-
public void testBeatsProtocolNumberAsString() throws Exception {
145+
public void testBeatsProtocolNumberAsString() {
146146
@SuppressWarnings("unchecked")
147147
var source = (Map<String, Object>) event.get("source");
148148
source.remove("port");
@@ -155,7 +155,7 @@ public void testBeatsProtocolNumberAsString() throws Exception {
155155
testCommunityIdProcessor(event, "1:D3t8Q1aFA6Ev0A/AO4i9PnU3AeI=");
156156
}
157157

158-
public void testBeatsProtocolNumber() throws Exception {
158+
public void testBeatsProtocolNumber() {
159159
@SuppressWarnings("unchecked")
160160
var source = (Map<String, Object>) event.get("source");
161161
source.remove("port");
@@ -168,15 +168,15 @@ public void testBeatsProtocolNumber() throws Exception {
168168
testCommunityIdProcessor(event, "1:D3t8Q1aFA6Ev0A/AO4i9PnU3AeI=");
169169
}
170170

171-
public void testBeatsIanaNumberProtocolTCP() throws Exception {
171+
public void testBeatsIanaNumberProtocolTCP() {
172172
@SuppressWarnings("unchecked")
173173
var network = (Map<String, Object>) event.get("network");
174174
network.remove("transport");
175175
network.put("iana_number", CommunityIdProcessor.Transport.Type.Tcp.getTransportNumber());
176176
testCommunityIdProcessor(event, "1:LQU9qZlK+B5F3KDmev6m5PMibrg=");
177177
}
178178

179-
public void testBeatsIanaNumberProtocolIPv4() throws Exception {
179+
public void testBeatsIanaNumberProtocolIPv4() {
180180
@SuppressWarnings("unchecked")
181181
var network = (Map<String, Object>) event.get("network");
182182
network.put("iana_number", "4");
@@ -192,7 +192,7 @@ public void testBeatsIanaNumberProtocolIPv4() throws Exception {
192192
testCommunityIdProcessor(event, "1:KXQzmk3bdsvD6UXj7dvQ4bM6Zvw=");
193193
}
194194

195-
public void testIpv6() throws Exception {
195+
public void testIpv6() {
196196
@SuppressWarnings("unchecked")
197197
var source = (Map<String, Object>) event.get("source");
198198
source.put("ip", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
@@ -202,7 +202,7 @@ public void testIpv6() throws Exception {
202202
testCommunityIdProcessor(event, "1:YC1+javPJ2LpK5xVyw1udfT83Qs=");
203203
}
204204

205-
public void testIcmpWithCodeEquivalent() throws Exception {
205+
public void testIcmpWithCodeEquivalent() {
206206
@SuppressWarnings("unchecked")
207207
var network = (Map<String, Object>) event.get("network");
208208
network.put("transport", "icmp");
@@ -213,7 +213,7 @@ public void testIcmpWithCodeEquivalent() throws Exception {
213213
testCommunityIdProcessor(event, "1:L8wnzpmRHIESLqLBy+zTqW3Pmqs=");
214214
}
215215

216-
public void testStringAndNumber() throws Exception {
216+
public void testStringAndNumber() {
217217
// iana
218218
event = buildEvent();
219219
@SuppressWarnings("unchecked")
@@ -279,23 +279,23 @@ public void testStringAndNumber() throws Exception {
279279
testCommunityIdProcessor(event, "1:KF3iG9XD24nhlSy4r1TcYIr5mfE=");
280280
}
281281

282-
public void testLongsForNumericValues() throws Exception {
282+
public void testLongsForNumericValues() {
283283
event = buildEvent();
284284
@SuppressWarnings("unchecked")
285285
var source2 = (Map<String, Object>) event.get("source");
286286
source2.put("port", 34855L);
287287
testCommunityIdProcessor(event, "1:LQU9qZlK+B5F3KDmev6m5PMibrg=");
288288
}
289289

290-
public void testFloatsForNumericValues() throws Exception {
290+
public void testFloatsForNumericValues() {
291291
event = buildEvent();
292292
@SuppressWarnings("unchecked")
293293
var source2 = (Map<String, Object>) event.get("source");
294294
source2.put("port", 34855.0);
295295
testCommunityIdProcessor(event, "1:LQU9qZlK+B5F3KDmev6m5PMibrg=");
296296
}
297297

298-
public void testInvalidPort() throws Exception {
298+
public void testInvalidPort() {
299299
event = buildEvent();
300300
@SuppressWarnings("unchecked")
301301
var source = (Map<String, Object>) event.get("source");
@@ -325,14 +325,14 @@ public void testInvalidPort() throws Exception {
325325
assertThat(e.getMessage(), containsString("invalid destination port [65536]"));
326326
}
327327

328-
public void testIgnoreMissing() throws Exception {
328+
public void testIgnoreMissing() {
329329
@SuppressWarnings("unchecked")
330330
var network = (Map<String, Object>) event.get("network");
331331
network.remove("transport");
332332
testCommunityIdProcessor(event, 0, null, true);
333333
}
334334

335-
public void testIgnoreMissingIsFalse() throws Exception {
335+
public void testIgnoreMissingIsFalse() {
336336
@SuppressWarnings("unchecked")
337337
var source = (Map<String, Object>) event.get("source");
338338
source.remove("ip");
@@ -342,16 +342,15 @@ public void testIgnoreMissingIsFalse() throws Exception {
342342
assertThat(e.getMessage(), containsString("field [ip] not present as part of path [source.ip]"));
343343
}
344344

345-
private void testCommunityIdProcessor(Map<String, Object> source, String expectedHash) throws Exception {
345+
private void testCommunityIdProcessor(Map<String, Object> source, String expectedHash) {
346346
testCommunityIdProcessor(source, 0, expectedHash);
347347
}
348348

349-
private void testCommunityIdProcessor(Map<String, Object> source, int seed, String expectedHash) throws Exception {
349+
private void testCommunityIdProcessor(Map<String, Object> source, int seed, String expectedHash) {
350350
testCommunityIdProcessor(source, seed, expectedHash, false);
351351
}
352352

353-
private void testCommunityIdProcessor(Map<String, Object> source, int seed, String expectedHash, boolean ignoreMissing)
354-
throws Exception {
353+
private void testCommunityIdProcessor(Map<String, Object> source, int seed, String expectedHash, boolean ignoreMissing) {
355354
var processor = new CommunityIdProcessor(
356355
null,
357356
null,

0 commit comments

Comments
 (0)