2 * ===============================LICENSE_START======================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============================LICENSE_END===========================================
\r
21 package org.openecomp.dcae.apod.analytics.tca.utils;
\r
23 import com.google.common.base.Supplier;
\r
24 import com.google.common.collect.ImmutableSet;
\r
25 import com.google.common.collect.Table;
\r
26 import org.apache.commons.lang3.tuple.Pair;
\r
27 import org.junit.Rule;
\r
28 import org.junit.Test;
\r
29 import org.junit.rules.ExpectedException;
\r
30 import org.mockito.Mockito;
\r
31 import org.openecomp.dcae.apod.analytics.common.AnalyticsConstants;
\r
32 import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
\r
33 import org.openecomp.dcae.apod.analytics.model.domain.cef.CommonEventHeader;
\r
34 import org.openecomp.dcae.apod.analytics.model.domain.cef.Domain;
\r
35 import org.openecomp.dcae.apod.analytics.model.domain.cef.Event;
\r
36 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
\r
37 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventSeverity;
\r
38 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.ClosedLoopEventStatus;
\r
39 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.ControlLoopSchemaType;
\r
40 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Direction;
\r
41 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerEventName;
\r
42 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
\r
43 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Threshold;
\r
44 import org.openecomp.dcae.apod.analytics.model.facade.tca.TCAVESResponse;
\r
45 import org.openecomp.dcae.apod.analytics.tca.BaseAnalyticsTCAUnitTest;
\r
46 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFProcessorContext;
\r
47 import org.quartz.Job;
\r
48 import org.quartz.JobDataMap;
\r
49 import org.quartz.JobDetail;
\r
50 import org.quartz.Scheduler;
\r
51 import org.quartz.SimpleTrigger;
\r
52 import org.quartz.impl.StdSchedulerFactory;
\r
54 import java.math.BigDecimal;
\r
55 import java.util.Arrays;
\r
56 import java.util.HashMap;
\r
57 import java.util.List;
\r
58 import java.util.Map;
\r
59 import java.util.Set;
\r
61 import static org.hamcrest.CoreMatchers.is;
\r
62 import static org.hamcrest.CoreMatchers.isA;
\r
63 import static org.hamcrest.Matchers.containsInAnyOrder;
\r
64 import static org.junit.Assert.assertEquals;
\r
65 import static org.junit.Assert.assertFalse;
\r
66 import static org.junit.Assert.assertNotNull;
\r
67 import static org.junit.Assert.assertNull;
\r
68 import static org.junit.Assert.assertThat;
\r
69 import static org.junit.Assert.assertTrue;
\r
70 import static org.mockito.Mockito.mock;
\r
71 import static org.mockito.Mockito.times;
\r
72 import static org.mockito.Mockito.verify;
\r
73 import static org.mockito.Mockito.when;
\r
76 * @author Rajiv Singla . Creation Date: 11/9/2016.
\r
78 public class TCAUtilsTest extends BaseAnalyticsTCAUnitTest {
\r
81 public void testGetPolicyEventNames() throws Exception {
\r
83 final TCAPolicy sampleTCAPolicy = getSampleTCAPolicy();
\r
84 final List<String> eventNames = TCAUtils.getPolicyEventNames(sampleTCAPolicy);
\r
86 assertThat("Policy event names must contain vFirewall, vLoadBalancer, virtualVMEventName", eventNames,
\r
87 containsInAnyOrder("Mfvs_eNodeB_RANKPI", "vLoadBalancer", "virtualVMEventName"));
\r
91 public void testGetPolicyEventNamesSupplier() throws Exception {
\r
92 final TCAPolicy sampleTCAPolicy = getSampleTCAPolicy();
\r
93 final Supplier<List<String>> policyEventNamesSupplier = TCAUtils.getPolicyEventNamesSupplier
\r
95 final List<String> eventNames = policyEventNamesSupplier.get();
\r
96 assertThat("Policy event names must contain vFirewall and vLoadBalancer", eventNames,
\r
97 containsInAnyOrder("Mfvs_eNodeB_RANKPI", "vLoadBalancer", "virtualVMEventName"));
\r
101 public void testProcessCEFMessage() throws Exception {
\r
102 final String cefMessageString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
\r
103 final TCACEFProcessorContext tcacefProcessorContext = TCAUtils.filterCEFMessage(cefMessageString,
\r
104 getSampleTCAPolicy());
\r
105 assertThat("TCAECEFProcessor Processor Context can continue flag is true", tcacefProcessorContext
\r
106 .canProcessingContinue(), is(true));
\r
110 public void testGetPolicyFRThresholdsTableSupplier() throws Exception {
\r
111 final Table<String, String, List<Threshold>> policyFRThresholdPathTable = TCAUtils
\r
112 .getPolicyEventNameThresholdsTableSupplier(getSampleTCAPolicy()).get();
\r
114 final Map<String, List<Threshold>> eNodeBRankpi = policyFRThresholdPathTable.row("Mfvs_eNodeB_RANKPI");
\r
115 final Map<String, List<Threshold>> vLoadBalancer = policyFRThresholdPathTable.row("vLoadBalancer");
\r
117 final Set<String> eNodeBRankpiFieldPaths = eNodeBRankpi.keySet();
\r
118 final Set<String> vLoadBalancerPaths = vLoadBalancer.keySet();
\r
120 final String receivedBroadcastPacketsFieldPath =
\r
121 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated";
\r
122 assertThat("eNodeBRankpi threshold field path size must be " +
\r
123 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*]" +
\r
124 ".receivedBroadcastPacketsAccumulated",
\r
125 eNodeBRankpiFieldPaths.iterator().next(),
\r
126 is(receivedBroadcastPacketsFieldPath));
\r
128 assertThat("vLoadBalancer threshold field path size must be " +
\r
129 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*]" +
\r
130 ".receivedBroadcastPacketsAccumulated",
\r
131 vLoadBalancerPaths.iterator().next(),
\r
132 is(receivedBroadcastPacketsFieldPath));
\r
134 final List<Threshold> eNodeBRankpiThresholds = policyFRThresholdPathTable.get("Mfvs_eNodeB_RANKPI",
\r
135 receivedBroadcastPacketsFieldPath);
\r
136 final List<Threshold> vLoadBalancerThresholds = policyFRThresholdPathTable.get("vLoadBalancer",
\r
137 receivedBroadcastPacketsFieldPath);
\r
139 assertThat("eNodeBRankpi Threshold size must be 3", eNodeBRankpiThresholds.size(), is(3));
\r
140 assertThat("vLoadBalancer Threshold size must be 2", vLoadBalancerThresholds.size(), is(2));
\r
144 public void testGetJsonPathValueWithValidMessageAndPolicy() throws Exception {
\r
145 final String cefMessageString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
\r
146 final String jsonPath =
\r
147 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated";
\r
148 final ImmutableSet<String> fieldPaths = ImmutableSet.of(jsonPath);
\r
149 final Map<String, List<BigDecimal>> jsonPathValueMap = TCAUtils.getJsonPathValue(cefMessageString, fieldPaths);
\r
150 assertThat("Json Path value must match",
\r
151 jsonPathValueMap.get(jsonPath).get(0), is(new BigDecimal(5000)));
\r
156 public void testGetJsonPathValueWithValidPath() throws Exception {
\r
157 final String cefMessageString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
\r
158 final String jsonPath = "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].invalid";
\r
159 final ImmutableSet<String> fieldPaths = ImmutableSet.of(jsonPath);
\r
160 final Map<String, List<BigDecimal>> jsonPathValueMap = TCAUtils.getJsonPathValue(cefMessageString, fieldPaths);
\r
161 assertThat("Json path value must be empty", jsonPathValueMap.size(), is(0));
\r
167 public void testCreateNewTCAVESResponseWithVFControlLoopSchemaType() throws Exception {
\r
168 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
170 MetricsPerEventName metricsPerEventName = mock(MetricsPerEventName.class);
\r
171 when(metricsPerEventName.getThresholds()).thenReturn(getThresholds());
\r
172 when(metricsPerEventName.getPolicyScope()).thenReturn("Test Policy scope");
\r
173 when(tcacefProcessorContext.getMetricsPerEventName()).thenReturn(metricsPerEventName);
\r
174 when(metricsPerEventName.getEventName()).thenReturn("testEventName");
\r
175 when(metricsPerEventName.getControlLoopSchemaType()).thenReturn(ControlLoopSchemaType.VM);
\r
177 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
178 TCAVESResponse tcaVESResponse = TCAUtils.createNewTCAVESResponse(tcacefProcessorContext, "TCA_APP_NAME");
\r
180 //TODO : Add proper assertions, as the usage is not clearly understood
\r
181 assertThat(tcaVESResponse.getClosedLoopControlName(),
\r
182 is("CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A"));
\r
183 assertThat(tcaVESResponse.getVersion(), is("Test Version"));
\r
184 assertThat(tcaVESResponse.getPolicyScope(), is("Test Policy scope"));
\r
185 assertNull(tcaVESResponse.getAai().getGenericVNFName());
\r
186 assertNotNull(tcaVESResponse.getAai().getGenericServerName());
\r
190 public void testCreateNewTCAVESResponseWithFunctionalRolevFirewall() throws Exception {
\r
191 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
193 MetricsPerEventName metricsPerEventName = mock(MetricsPerEventName.class);
\r
194 when(metricsPerEventName.getThresholds()).thenReturn(getThresholds());
\r
195 when(metricsPerEventName.getPolicyScope()).thenReturn("Test Policy scope");
\r
196 when(tcacefProcessorContext.getMetricsPerEventName()).thenReturn(metricsPerEventName);
\r
197 when(metricsPerEventName.getEventName()).thenReturn("vFirewall");
\r
199 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
200 TCAVESResponse tcaVESResponse = TCAUtils.createNewTCAVESResponse(tcacefProcessorContext, "TCA_APP_NAME");
\r
202 //TODO : Add proper assertions, as the usage is not clearly understood
\r
203 assertThat(tcaVESResponse.getClosedLoopControlName(),
\r
204 is("CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A"));
\r
205 assertThat(tcaVESResponse.getVersion(), is("Test Version"));
\r
206 assertThat(tcaVESResponse.getPolicyScope(), is("Test Policy scope"));
\r
207 assertNotNull(tcaVESResponse.getAai().getGenericVNFName());
\r
208 assertNull(tcaVESResponse.getAai().getGenericServerName());
\r
213 public ExpectedException expectedIllegalArgumentException = ExpectedException.none();
\r
216 public void testCreateNewTCAVESResponseNullFunctionalRole() throws Exception {
\r
217 expectedIllegalArgumentException.expect(MessageProcessingException.class);
\r
218 expectedIllegalArgumentException.expectCause(isA(IllegalArgumentException.class));
\r
219 expectedIllegalArgumentException.expectMessage("No violations metrics. Unable to create VES Response");
\r
221 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
222 TCAVESResponse tcaVESResponse = TCAUtils.createNewTCAVESResponse(tcacefProcessorContext, "TCA_APP_NAME");
\r
223 assertNotNull(tcaVESResponse.getClosedLoopControlName());
\r
227 public void testPrioritizeThresholdViolations() throws Exception {
\r
229 Map<String, Threshold> thresholdMap = new HashMap<>();
\r
230 Threshold majorThreshold = mock(Threshold.class);
\r
231 when(majorThreshold.getSeverity()).thenReturn(EventSeverity.MAJOR);
\r
232 thresholdMap.put("MAJOR", majorThreshold);
\r
234 Threshold result1 = TCAUtils.prioritizeThresholdViolations(thresholdMap);
\r
235 assertEquals(result1.getSeverity(), EventSeverity.MAJOR);
\r
237 Threshold criticalThreshold = mock(Threshold.class);
\r
238 when(criticalThreshold.getSeverity()).thenReturn(EventSeverity.CRITICAL);
\r
239 thresholdMap.put("CRITICAL", criticalThreshold);
\r
241 Threshold result2 = TCAUtils.prioritizeThresholdViolations(thresholdMap);
\r
242 assertEquals(result2.getSeverity(), EventSeverity.CRITICAL);
\r
246 public void testCreateViolatedMetrics() throws Exception {
\r
247 TCAPolicy tcaPolicy = getSampleTCAPolicy();
\r
248 Threshold violatedThreshold = getCriticalThreshold();
\r
249 String functionalRole = "Mfvs_eNodeB_RANKPI";
\r
250 MetricsPerEventName result = TCAUtils.createViolatedMetrics(tcaPolicy, violatedThreshold, functionalRole);
\r
251 assertThat(result.getPolicyScope(), is("resource=vFirewall;type=configuration"));
\r
252 assertThat(result.getPolicyName(), is("configuration.dcae.microservice.tca.xml"));
\r
256 public void testCreateViolatedMetricsWrongEventName() throws Exception {
\r
257 expectedIllegalArgumentException.expect(MessageProcessingException.class);
\r
258 expectedIllegalArgumentException.expectCause(isA(IllegalStateException.class));
\r
259 String eventName = "badEventName";
\r
260 expectedIllegalArgumentException.expectMessage("TCA Policy must contain eventName: " + eventName);
\r
261 TCAPolicy tcaPolicy = getSampleTCAPolicy();
\r
262 Threshold violatedThreshold = getCriticalThreshold();
\r
263 TCAUtils.createViolatedMetrics(tcaPolicy, violatedThreshold, eventName);
\r
267 public void testGetDomainAndEventName() {
\r
268 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
269 EventListener eventListener = mock(EventListener.class);
\r
270 Event event = mock(Event.class);
\r
271 CommonEventHeader commonEventHeader = mock(CommonEventHeader.class);
\r
273 Pair<String, String> result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
274 assertNull(result.getLeft());
\r
275 assertNull(result.getRight());
\r
277 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(eventListener);
\r
278 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
279 assertNull(result.getLeft());
\r
280 assertNull(result.getRight());
\r
282 when(eventListener.getEvent()).thenReturn(event);
\r
283 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
284 assertNull(result.getLeft());
\r
285 assertNull(result.getRight());
\r
287 when(event.getCommonEventHeader()).thenReturn(commonEventHeader);
\r
288 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
289 assertNull(result.getLeft());
\r
290 assertNull(result.getRight());
\r
292 when(commonEventHeader.getDomain()).thenReturn(Domain.other);
\r
293 when(commonEventHeader.getEventName()).thenReturn("eventName");
\r
295 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
296 assertEquals(result.getLeft(), "other");
\r
297 assertEquals(result.getRight(), "eventName");
\r
302 public void testComputeThresholdViolationsNotPresent() throws Exception {
\r
303 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
304 when(tcacefProcessorContext.canProcessingContinue()).thenReturn(true);
\r
305 when(tcacefProcessorContext.getMessage()).thenReturn(getValidCEFMessage());
\r
307 when(tcacefProcessorContext.getTCAPolicy()).thenReturn(getSampleTCAPolicy());
\r
308 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
310 TCACEFProcessorContext result = TCAUtils.computeThresholdViolations(tcacefProcessorContext);
\r
311 assertNotNull(result);
\r
312 verify(result, times(0)).setMetricsPerEventName(Mockito.any(MetricsPerEventName.class));
\r
313 assertEquals("Policy must not change", getSampleTCAPolicy(), result.getTCAPolicy());
\r
317 public void testComputeThresholdViolationsPresent() throws Exception {
\r
318 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
319 when(tcacefProcessorContext.canProcessingContinue()).thenReturn(true);
\r
320 final String cefMessageString = fromStream(CEF_MESSAGE_WITH_THRESHOLD_VIOLATION_JSON_FILE_LOCATION);
\r
321 when(tcacefProcessorContext.getMessage()).thenReturn(cefMessageString);
\r
323 when(tcacefProcessorContext.getTCAPolicy()).thenReturn(getSampleTCAPolicy());
\r
324 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
326 TCACEFProcessorContext result = TCAUtils.computeThresholdViolations(tcacefProcessorContext);
\r
327 verify(result, times(1)).setMetricsPerEventName(Mockito.any(MetricsPerEventName.class));
\r
329 assertEquals("Policy must not change", getSampleTCAPolicy(), result.getTCAPolicy());
\r
334 public void testCreateTCAPolicyMetricsPerKeyName() throws Exception {
\r
336 final Map<String, String> tcaPolicyMap = TCAUtils.filterMapByKeyNamePrefix(getControllerRuntimeArguments(),
\r
337 AnalyticsConstants.TCA_POLICY_METRICS_PER_FUNCTIONAL_ROLE_PATH);
\r
339 // determine functional Roles
\r
340 final Map<String, Map<String, String>> functionalRolesMap =
\r
341 TCAUtils.extractSubTree(tcaPolicyMap, 2, 3, AnalyticsConstants.TCA_POLICY_DELIMITER);
\r
343 final List<MetricsPerEventName> tcaPolicyMetricsPerEventNameList =
\r
344 TCAUtils.createTCAPolicyMetricsPerEventNameList(functionalRolesMap);
\r
346 assertThat("There are two Metrics per function role", 2,
\r
347 is(tcaPolicyMetricsPerEventNameList.size()));
\r
352 public void testCreateQuartzScheduler() throws Exception {
\r
353 final Scheduler scheduler = Mockito.mock(Scheduler.class);
\r
354 final StdSchedulerFactory stdSchedulerFactory = Mockito.mock(StdSchedulerFactory.class);
\r
355 when(stdSchedulerFactory.getScheduler()).thenReturn(scheduler);
\r
356 final JobDataMap jobDataMap = Mockito.mock(JobDataMap.class);
\r
357 TCAUtils.createQuartzScheduler(1000, stdSchedulerFactory,
\r
358 "data/properties/quartz-test.properties", jobDataMap, Job.class,
\r
359 "testJob", "testTigger");
\r
360 verify(scheduler, times(1))
\r
361 .scheduleJob(Mockito.any(JobDetail.class), Mockito.any(SimpleTrigger.class));
\r
366 public void testCreateTCAAlertStringWhenCEFIsEnabled() throws Exception {
\r
367 final MetricsPerEventName violatedMetrics = createViolatedMetricsPerEventName(EventSeverity.CRITICAL);
\r
368 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
369 when(processorContext.getMetricsPerEventName()).thenReturn(violatedMetrics);
\r
370 when(processorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
371 final String alertString = TCAUtils.createTCAAlertString(processorContext, "testApp", true);
\r
372 assertTrue(alertString.contains("thresholdCrossingAlertFields"));
\r
375 @Test(expected = MessageProcessingException.class)
\r
376 public void testCreateTCAAlertStringWhenViolatedMetricsNotPresentAndCEFIsEnabled() throws Exception {
\r
377 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
378 when(processorContext.getMetricsPerEventName()).thenReturn(null);
\r
379 TCAUtils.createTCAAlertString(processorContext, "testApp", true);
\r
383 public void testCreateTCAAlertStringWhenCEFIsDisabled() throws Exception {
\r
384 final MetricsPerEventName violatedMetrics = createViolatedMetricsPerEventName(EventSeverity.MAJOR);
\r
385 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
386 when(processorContext.getMetricsPerEventName()).thenReturn(violatedMetrics);
\r
387 when(processorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
388 final String alertString = TCAUtils.createTCAAlertString(processorContext, "testApp", false);
\r
389 assertFalse(alertString.contains("thresholdCrossingAlertFields"));
\r
392 @Test(expected = MessageProcessingException.class)
\r
393 public void testCreateTCAAlertStringWhenViolatedMetricsNotPresentAndCEFIsDisabled() throws Exception {
\r
394 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
395 when(processorContext.getMetricsPerEventName()).thenReturn(null);
\r
396 TCAUtils.createTCAAlertString(processorContext, "testApp", false);
\r
399 private static MetricsPerEventName createViolatedMetricsPerEventName(EventSeverity severity) {
\r
400 final Threshold violatedThreshold = new Threshold();
\r
401 violatedThreshold.setSeverity(severity);
\r
402 violatedThreshold.setDirection(Direction.GREATER);
\r
403 violatedThreshold.setClosedLoopControlName("violatedThresholdClosedLoopName");
\r
404 violatedThreshold.setActualFieldValue(new BigDecimal(100L));
\r
405 violatedThreshold.setFieldPath("violatedThresholdFieldPath");
\r
406 violatedThreshold.setVersion("violatedThresholdVersion");
\r
407 violatedThreshold.setClosedLoopEventStatus(ClosedLoopEventStatus.ONSET);
\r
408 violatedThreshold.setThresholdValue(50L);
\r
410 final MetricsPerEventName violatedMetrics = new MetricsPerEventName();
\r
411 violatedMetrics.setPolicyName("violatePolicyName");
\r
412 violatedMetrics.setPolicyVersion("violatedPolicyVersion");
\r
413 violatedMetrics.setPolicyScope("violatedPolicyScope");
\r
414 violatedMetrics.setEventName("violatedEventName");
\r
415 violatedMetrics.setThresholds(Arrays.asList(violatedThreshold));
\r
416 return violatedMetrics;
\r