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.fasterxml.jackson.databind.JsonNode;
\r
24 import com.google.common.base.Supplier;
\r
25 import com.google.common.collect.ImmutableSet;
\r
26 import com.google.common.collect.Table;
\r
27 import org.apache.commons.lang3.tuple.Pair;
\r
28 import org.junit.Rule;
\r
29 import org.junit.Test;
\r
30 import org.junit.rules.ExpectedException;
\r
31 import org.mockito.Mockito;
\r
32 import org.openecomp.dcae.apod.analytics.common.AnalyticsConstants;
\r
33 import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
\r
34 import org.openecomp.dcae.apod.analytics.model.domain.cef.CommonEventHeader;
\r
35 import org.openecomp.dcae.apod.analytics.model.domain.cef.Domain;
\r
36 import org.openecomp.dcae.apod.analytics.model.domain.cef.Event;
\r
37 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
\r
38 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventSeverity;
\r
39 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.ClosedLoopEventStatus;
\r
40 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.ControlLoopSchemaType;
\r
41 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Direction;
\r
42 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerEventName;
\r
43 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
\r
44 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Threshold;
\r
45 import org.openecomp.dcae.apod.analytics.model.facade.tca.AAI;
\r
46 import org.openecomp.dcae.apod.analytics.model.facade.tca.TCAVESResponse;
\r
47 import org.openecomp.dcae.apod.analytics.tca.BaseAnalyticsTCAUnitTest;
\r
48 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFProcessorContext;
\r
49 import org.quartz.Job;
\r
50 import org.quartz.JobDataMap;
\r
51 import org.quartz.JobDetail;
\r
52 import org.quartz.Scheduler;
\r
53 import org.quartz.SimpleTrigger;
\r
54 import org.quartz.impl.StdSchedulerFactory;
\r
56 import java.math.BigDecimal;
\r
57 import java.util.Arrays;
\r
58 import java.util.HashMap;
\r
59 import java.util.List;
\r
60 import java.util.Map;
\r
61 import java.util.Set;
\r
63 import static org.hamcrest.CoreMatchers.is;
\r
64 import static org.hamcrest.CoreMatchers.isA;
\r
65 import static org.hamcrest.Matchers.containsInAnyOrder;
\r
66 import static org.junit.Assert.assertEquals;
\r
67 import static org.junit.Assert.assertFalse;
\r
68 import static org.junit.Assert.assertNotNull;
\r
69 import static org.junit.Assert.assertNull;
\r
70 import static org.junit.Assert.assertThat;
\r
71 import static org.junit.Assert.assertTrue;
\r
72 import static org.mockito.Mockito.mock;
\r
73 import static org.mockito.Mockito.times;
\r
74 import static org.mockito.Mockito.verify;
\r
75 import static org.mockito.Mockito.when;
\r
78 * @author Rajiv Singla . Creation Date: 11/9/2016.
\r
80 public class TCAUtilsTest extends BaseAnalyticsTCAUnitTest {
\r
83 public void testGetPolicyEventNames() throws Exception {
\r
85 final TCAPolicy sampleTCAPolicy = getSampleTCAPolicy();
\r
86 final List<String> eventNames = TCAUtils.getPolicyEventNames(sampleTCAPolicy);
\r
88 assertThat("Policy event names must contain vFirewall, vLoadBalancer, virtualVMEventName", eventNames,
\r
89 containsInAnyOrder("Mfvs_eNodeB_RANKPI", "vLoadBalancer", "virtualVMEventName"));
\r
93 public void testGetPolicyEventNamesSupplier() throws Exception {
\r
94 final TCAPolicy sampleTCAPolicy = getSampleTCAPolicy();
\r
95 final Supplier<List<String>> policyEventNamesSupplier = TCAUtils.getPolicyEventNamesSupplier
\r
97 final List<String> eventNames = policyEventNamesSupplier.get();
\r
98 assertThat("Policy event names must contain vFirewall and vLoadBalancer", eventNames,
\r
99 containsInAnyOrder("Mfvs_eNodeB_RANKPI", "vLoadBalancer", "virtualVMEventName"));
\r
103 public void testProcessCEFMessage() throws Exception {
\r
104 final String cefMessageString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
\r
105 final TCACEFProcessorContext tcacefProcessorContext = TCAUtils.filterCEFMessage(cefMessageString,
\r
106 getSampleTCAPolicy());
\r
107 assertThat("TCAECEFProcessor Processor Context can continue flag is true", tcacefProcessorContext
\r
108 .canProcessingContinue(), is(true));
\r
112 public void testGetPolicyFRThresholdsTableSupplier() throws Exception {
\r
113 final Table<String, String, List<Threshold>> policyFRThresholdPathTable = TCAUtils
\r
114 .getPolicyEventNameThresholdsTableSupplier(getSampleTCAPolicy()).get();
\r
116 final Map<String, List<Threshold>> eNodeBRankpi = policyFRThresholdPathTable.row("Mfvs_eNodeB_RANKPI");
\r
117 final Map<String, List<Threshold>> vLoadBalancer = policyFRThresholdPathTable.row("vLoadBalancer");
\r
119 final Set<String> eNodeBRankpiFieldPaths = eNodeBRankpi.keySet();
\r
120 final Set<String> vLoadBalancerPaths = vLoadBalancer.keySet();
\r
122 final String receivedBroadcastPacketsFieldPath =
\r
123 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated";
\r
124 assertThat("eNodeBRankpi threshold field path size must be " +
\r
125 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*]" +
\r
126 ".receivedBroadcastPacketsAccumulated",
\r
127 eNodeBRankpiFieldPaths.iterator().next(),
\r
128 is(receivedBroadcastPacketsFieldPath));
\r
130 assertThat("vLoadBalancer threshold field path size must be " +
\r
131 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*]" +
\r
132 ".receivedBroadcastPacketsAccumulated",
\r
133 vLoadBalancerPaths.iterator().next(),
\r
134 is(receivedBroadcastPacketsFieldPath));
\r
136 final List<Threshold> eNodeBRankpiThresholds = policyFRThresholdPathTable.get("Mfvs_eNodeB_RANKPI",
\r
137 receivedBroadcastPacketsFieldPath);
\r
138 final List<Threshold> vLoadBalancerThresholds = policyFRThresholdPathTable.get("vLoadBalancer",
\r
139 receivedBroadcastPacketsFieldPath);
\r
141 assertThat("eNodeBRankpi Threshold size must be 3", eNodeBRankpiThresholds.size(), is(3));
\r
142 assertThat("vLoadBalancer Threshold size must be 2", vLoadBalancerThresholds.size(), is(2));
\r
146 public void testGetJsonPathValueWithValidMessageAndPolicy() throws Exception {
\r
147 final String cefMessageString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
\r
148 final String jsonPath =
\r
149 "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated";
\r
150 final ImmutableSet<String> fieldPaths = ImmutableSet.of(jsonPath);
\r
151 final Map<String, List<BigDecimal>> jsonPathValueMap = TCAUtils.getJsonPathValue(cefMessageString, fieldPaths);
\r
152 assertThat("Json Path value must match",
\r
153 jsonPathValueMap.get(jsonPath).get(0), is(new BigDecimal(5000)));
\r
158 public void testGetJsonPathValueWithValidPath() throws Exception {
\r
159 final String cefMessageString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
\r
160 final String jsonPath = "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].invalid";
\r
161 final ImmutableSet<String> fieldPaths = ImmutableSet.of(jsonPath);
\r
162 final Map<String, List<BigDecimal>> jsonPathValueMap = TCAUtils.getJsonPathValue(cefMessageString, fieldPaths);
\r
163 assertThat("Json path value must be empty", jsonPathValueMap.size(), is(0));
\r
169 public void testCreateNewTCAVESResponseWithVFControlLoopSchemaType() throws Exception {
\r
170 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
172 MetricsPerEventName metricsPerEventName = mock(MetricsPerEventName.class);
\r
173 when(metricsPerEventName.getThresholds()).thenReturn(getThresholds());
\r
174 when(metricsPerEventName.getPolicyScope()).thenReturn("Test Policy scope");
\r
175 when(tcacefProcessorContext.getMetricsPerEventName()).thenReturn(metricsPerEventName);
\r
176 when(metricsPerEventName.getEventName()).thenReturn("testEventName");
\r
177 when(metricsPerEventName.getControlLoopSchemaType()).thenReturn(ControlLoopSchemaType.VM);
\r
179 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
180 TCAVESResponse tcaVESResponse = TCAUtils.createNewTCAVESResponse(tcacefProcessorContext, "TCA_APP_NAME");
\r
182 //TODO : Add proper assertions, as the usage is not clearly understood
\r
183 assertThat(tcaVESResponse.getClosedLoopControlName(),
\r
184 is("CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A"));
\r
185 assertThat(tcaVESResponse.getVersion(), is("Test Version"));
\r
186 assertThat(tcaVESResponse.getPolicyScope(), is("Test Policy scope"));
\r
187 assertNull(tcaVESResponse.getAai().getGenericVNFId());
\r
188 assertNotNull(tcaVESResponse.getAai().getGenericServerId());
\r
192 public void testCreateNewTCAVESResponseWithFunctionalRolevFirewall() throws Exception {
\r
193 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
195 MetricsPerEventName metricsPerEventName = mock(MetricsPerEventName.class);
\r
196 when(metricsPerEventName.getThresholds()).thenReturn(getThresholds());
\r
197 when(metricsPerEventName.getPolicyScope()).thenReturn("Test Policy scope");
\r
198 when(tcacefProcessorContext.getMetricsPerEventName()).thenReturn(metricsPerEventName);
\r
199 when(metricsPerEventName.getEventName()).thenReturn("vFirewall");
\r
201 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
202 TCAVESResponse tcaVESResponse = TCAUtils.createNewTCAVESResponse(tcacefProcessorContext, "TCA_APP_NAME");
\r
204 //TODO : Add proper assertions, as the usage is not clearly understood
\r
205 assertThat(tcaVESResponse.getClosedLoopControlName(),
\r
206 is("CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A"));
\r
207 assertThat(tcaVESResponse.getVersion(), is("Test Version"));
\r
208 assertThat(tcaVESResponse.getPolicyScope(), is("Test Policy scope"));
\r
209 assertNotNull(tcaVESResponse.getAai().getGenericVNFId());
\r
210 assertNull(tcaVESResponse.getAai().getGenericServerId());
\r
214 public ExpectedException expectedIllegalArgumentException = ExpectedException.none();
\r
217 public void testCreateNewTCAVESResponseNullFunctionalRole() throws Exception {
\r
218 expectedIllegalArgumentException.expect(MessageProcessingException.class);
\r
219 expectedIllegalArgumentException.expectCause(isA(IllegalArgumentException.class));
\r
220 expectedIllegalArgumentException.expectMessage("No violations metrics. Unable to create VES Response");
\r
222 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
223 TCAVESResponse tcaVESResponse = TCAUtils.createNewTCAVESResponse(tcacefProcessorContext, "TCA_APP_NAME");
\r
224 assertNotNull(tcaVESResponse.getClosedLoopControlName());
\r
228 public void testPrioritizeThresholdViolations() throws Exception {
\r
230 Map<String, Threshold> thresholdMap = new HashMap<>();
\r
231 Threshold majorThreshold = mock(Threshold.class);
\r
232 when(majorThreshold.getSeverity()).thenReturn(EventSeverity.MAJOR);
\r
233 thresholdMap.put("MAJOR", majorThreshold);
\r
235 Threshold result1 = TCAUtils.prioritizeThresholdViolations(thresholdMap);
\r
236 assertEquals(result1.getSeverity(), EventSeverity.MAJOR);
\r
238 Threshold criticalThreshold = mock(Threshold.class);
\r
239 when(criticalThreshold.getSeverity()).thenReturn(EventSeverity.CRITICAL);
\r
240 thresholdMap.put("CRITICAL", criticalThreshold);
\r
242 Threshold result2 = TCAUtils.prioritizeThresholdViolations(thresholdMap);
\r
243 assertEquals(result2.getSeverity(), EventSeverity.CRITICAL);
\r
247 public void testCreateViolatedMetrics() throws Exception {
\r
248 TCAPolicy tcaPolicy = getSampleTCAPolicy();
\r
249 Threshold violatedThreshold = getCriticalThreshold();
\r
250 String functionalRole = "Mfvs_eNodeB_RANKPI";
\r
251 MetricsPerEventName result = TCAUtils.createViolatedMetrics(tcaPolicy, violatedThreshold, functionalRole);
\r
252 assertThat(result.getPolicyScope(), is("resource=vFirewall;type=configuration"));
\r
253 assertThat(result.getPolicyName(), is("configuration.dcae.microservice.tca.xml"));
\r
257 public void testCreateViolatedMetricsWrongEventName() throws Exception {
\r
258 expectedIllegalArgumentException.expect(MessageProcessingException.class);
\r
259 expectedIllegalArgumentException.expectCause(isA(IllegalStateException.class));
\r
260 String eventName = "badEventName";
\r
261 expectedIllegalArgumentException.expectMessage("TCA Policy must contain eventName: " + eventName);
\r
262 TCAPolicy tcaPolicy = getSampleTCAPolicy();
\r
263 Threshold violatedThreshold = getCriticalThreshold();
\r
264 TCAUtils.createViolatedMetrics(tcaPolicy, violatedThreshold, eventName);
\r
268 public void testGetDomainAndEventName() {
\r
269 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
270 EventListener eventListener = mock(EventListener.class);
\r
271 Event event = mock(Event.class);
\r
272 CommonEventHeader commonEventHeader = mock(CommonEventHeader.class);
\r
274 Pair<String, String> result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
275 assertNull(result.getLeft());
\r
276 assertNull(result.getRight());
\r
278 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(eventListener);
\r
279 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
280 assertNull(result.getLeft());
\r
281 assertNull(result.getRight());
\r
283 when(eventListener.getEvent()).thenReturn(event);
\r
284 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
285 assertNull(result.getLeft());
\r
286 assertNull(result.getRight());
\r
288 when(event.getCommonEventHeader()).thenReturn(commonEventHeader);
\r
289 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
290 assertNull(result.getLeft());
\r
291 assertNull(result.getRight());
\r
293 when(commonEventHeader.getDomain()).thenReturn(Domain.other);
\r
294 when(commonEventHeader.getEventName()).thenReturn("eventName");
\r
296 result = TCAUtils.getDomainAndEventName(tcacefProcessorContext);
\r
297 assertEquals(result.getLeft(), "other");
\r
298 assertEquals(result.getRight(), "eventName");
\r
303 public void testComputeThresholdViolationsNotPresent() throws Exception {
\r
304 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
305 when(tcacefProcessorContext.canProcessingContinue()).thenReturn(true);
\r
306 when(tcacefProcessorContext.getMessage()).thenReturn(getValidCEFMessage());
\r
308 when(tcacefProcessorContext.getTCAPolicy()).thenReturn(getSampleTCAPolicy());
\r
309 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
311 TCACEFProcessorContext result = TCAUtils.computeThresholdViolations(tcacefProcessorContext);
\r
312 assertNotNull(result);
\r
313 verify(result, times(0)).setMetricsPerEventName(Mockito.any(MetricsPerEventName.class));
\r
314 assertEquals("Policy must not change", getSampleTCAPolicy(), result.getTCAPolicy());
\r
318 public void testComputeThresholdViolationsPresent() throws Exception {
\r
319 TCACEFProcessorContext tcacefProcessorContext = mock(TCACEFProcessorContext.class);
\r
320 when(tcacefProcessorContext.canProcessingContinue()).thenReturn(true);
\r
321 final String cefMessageString = fromStream(CEF_MESSAGE_WITH_THRESHOLD_VIOLATION_JSON_FILE_LOCATION);
\r
322 when(tcacefProcessorContext.getMessage()).thenReturn(cefMessageString);
\r
324 when(tcacefProcessorContext.getTCAPolicy()).thenReturn(getSampleTCAPolicy());
\r
325 when(tcacefProcessorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
327 TCACEFProcessorContext result = TCAUtils.computeThresholdViolations(tcacefProcessorContext);
\r
328 verify(result, times(1)).setMetricsPerEventName(Mockito.any(MetricsPerEventName.class));
\r
330 assertEquals("Policy must not change", getSampleTCAPolicy(), result.getTCAPolicy());
\r
335 public void testCreateTCAPolicyMetricsPerKeyName() throws Exception {
\r
337 final Map<String, String> tcaPolicyMap = TCAUtils.filterMapByKeyNamePrefix(getControllerRuntimeArguments(),
\r
338 AnalyticsConstants.TCA_POLICY_METRICS_PER_FUNCTIONAL_ROLE_PATH);
\r
340 // determine functional Roles
\r
341 final Map<String, Map<String, String>> functionalRolesMap =
\r
342 TCAUtils.extractSubTree(tcaPolicyMap, 2, 3, AnalyticsConstants.TCA_POLICY_DELIMITER);
\r
344 final List<MetricsPerEventName> tcaPolicyMetricsPerEventNameList =
\r
345 TCAUtils.createTCAPolicyMetricsPerEventNameList(functionalRolesMap);
\r
347 assertThat("There are two Metrics per function role", 2,
\r
348 is(tcaPolicyMetricsPerEventNameList.size()));
\r
353 public void testCreateQuartzScheduler() throws Exception {
\r
354 final Scheduler scheduler = Mockito.mock(Scheduler.class);
\r
355 final StdSchedulerFactory stdSchedulerFactory = Mockito.mock(StdSchedulerFactory.class);
\r
356 when(stdSchedulerFactory.getScheduler()).thenReturn(scheduler);
\r
357 final JobDataMap jobDataMap = Mockito.mock(JobDataMap.class);
\r
358 TCAUtils.createQuartzScheduler(1000, stdSchedulerFactory,
\r
359 "data/properties/quartz-test.properties", jobDataMap, Job.class,
\r
360 "testJob", "testTigger");
\r
361 verify(scheduler, times(1))
\r
362 .scheduleJob(Mockito.any(JobDetail.class), Mockito.any(SimpleTrigger.class));
\r
367 public void testCreateTCAAlertStringWhenCEFIsEnabled() throws Exception {
\r
368 final MetricsPerEventName violatedMetrics = createViolatedMetricsPerEventName(EventSeverity.CRITICAL);
\r
369 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
370 when(processorContext.getMetricsPerEventName()).thenReturn(violatedMetrics);
\r
371 when(processorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
372 final String alertString = TCAUtils.createTCAAlertString(processorContext, "testApp", true);
\r
373 assertTrue(alertString.contains("thresholdCrossingAlertFields"));
\r
376 @Test(expected = MessageProcessingException.class)
\r
377 public void testCreateTCAAlertStringWhenViolatedMetricsNotPresentAndCEFIsEnabled() throws Exception {
\r
378 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
379 when(processorContext.getMetricsPerEventName()).thenReturn(null);
\r
380 TCAUtils.createTCAAlertString(processorContext, "testApp", true);
\r
384 public void testCreateTCAAlertStringWhenCEFIsDisabled() throws Exception {
\r
385 final MetricsPerEventName violatedMetrics = createViolatedMetricsPerEventName(EventSeverity.MAJOR);
\r
386 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
387 when(processorContext.getMetricsPerEventName()).thenReturn(violatedMetrics);
\r
388 when(processorContext.getCEFEventListener()).thenReturn(getCEFEventListener());
\r
389 final String alertString = TCAUtils.createTCAAlertString(processorContext, "testApp", false);
\r
390 assertFalse(alertString.contains("thresholdCrossingAlertFields"));
\r
393 @Test(expected = MessageProcessingException.class)
\r
394 public void testCreateTCAAlertStringWhenViolatedMetricsNotPresentAndCEFIsDisabled() throws Exception {
\r
395 TCACEFProcessorContext processorContext = mock(TCACEFProcessorContext.class);
\r
396 when(processorContext.getMetricsPerEventName()).thenReturn(null);
\r
397 TCAUtils.createTCAAlertString(processorContext, "testApp", false);
\r
400 private static MetricsPerEventName createViolatedMetricsPerEventName(EventSeverity severity) {
\r
401 final Threshold violatedThreshold = new Threshold();
\r
402 violatedThreshold.setSeverity(severity);
\r
403 violatedThreshold.setDirection(Direction.GREATER);
\r
404 violatedThreshold.setClosedLoopControlName("violatedThresholdClosedLoopName");
\r
405 violatedThreshold.setActualFieldValue(new BigDecimal(100L));
\r
406 violatedThreshold.setFieldPath("violatedThresholdFieldPath");
\r
407 violatedThreshold.setVersion("violatedThresholdVersion");
\r
408 violatedThreshold.setClosedLoopEventStatus(ClosedLoopEventStatus.ONSET);
\r
409 violatedThreshold.setThresholdValue(50L);
\r
411 final MetricsPerEventName violatedMetrics = new MetricsPerEventName();
\r
412 violatedMetrics.setPolicyName("violatePolicyName");
\r
413 violatedMetrics.setPolicyVersion("violatedPolicyVersion");
\r
414 violatedMetrics.setPolicyScope("violatedPolicyScope");
\r
415 violatedMetrics.setEventName("violatedEventName");
\r
416 violatedMetrics.setThresholds(Arrays.asList(violatedThreshold));
\r
417 return violatedMetrics;
\r