2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.common.rules.test;
23 import static org.junit.Assert.assertEquals;
25 import java.util.List;
26 import java.util.UUID;
27 import java.util.function.Supplier;
28 import java.util.stream.Collectors;
29 import lombok.AccessLevel;
31 import org.junit.Test;
32 import org.onap.policy.appc.Request;
33 import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
34 import org.onap.policy.common.utils.coder.Coder;
35 import org.onap.policy.common.utils.coder.CoderException;
36 import org.onap.policy.common.utils.coder.StandardCoder;
37 import org.onap.policy.common.utils.coder.StandardCoderInstantAsMillis;
38 import org.onap.policy.controlloop.ControlLoopNotificationType;
39 import org.onap.policy.controlloop.VirtualControlLoopNotification;
40 import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2;
41 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
42 import org.onap.policy.sdnr.PciMessage;
45 * Superclass used for rule tests.
47 public abstract class BaseTest {
48 private static final String APPC_RESTART_OP = "restart";
49 private static final String APPC_MODIFY_CONFIG_OP = "ModifyConfig";
52 * Canonical Topic Names.
54 protected static final String DCAE_TOPIC = "DCAE_TOPIC";
55 protected static final String APPC_LCM_WRITE_TOPIC = "APPC-LCM-WRITE";
56 protected static final String POLICY_CL_MGT_TOPIC = "POLICY-CL-MGT";
57 protected static final String APPC_LCM_READ_TOPIC = "APPC-LCM-READ";
58 protected static final String APPC_CL_TOPIC = "APPC-CL";
59 protected static final String SDNR_CL_TOPIC = "SDNR-CL";
60 protected static final String SDNR_CL_RSP_TOPIC = "SDNR-CL-RSP";
63 * Constants for each test case.
66 // service123 (i.e., multi-operation policy)
67 private static final String SERVICE123_TOSCA_COMPLIANT_POLICY = "service123/tosca-compliant-service123.json";
68 private static final String SERVICE123_ONSET = "service123/service123.onset.json";
69 private static final String SERVICE123_APPC_RESTART_FAILURE = "service123/service123.appc.restart.failure.json";
70 private static final String SERVICE123_APPC_REBUILD_FAILURE = "service123/service123.appc.rebuild.failure.json";
71 private static final String SERVICE123_APPC_MIGRATE_SUCCESS = "service123/service123.appc.migrate.success.json";
73 // duplicates (i.e., mutliple events in the engine at the same time)
74 private static final String DUPLICATES_TOSCA_COMPLIANT_POLICY = "duplicates/tosca-compliant-duplicates.json";
75 private static final String DUPLICATES_ONSET_1 = "duplicates/duplicates.onset.1.json";
76 private static final String DUPLICATES_ONSET_2 = "duplicates/duplicates.onset.2.json";
77 private static final String DUPLICATES_APPC_SUCCESS = "duplicates/duplicates.appc.success.json";
80 private static final String VCPE_TOSCA_COMPLIANT_POLICY = "vcpe/tosca-compliant-vcpe.json";
81 private static final String VCPE_ONSET_1 = "vcpe/vcpe.onset.1.json";
82 private static final String VCPE_ONSET_2 = "vcpe/vcpe.onset.2.json";
83 private static final String VCPE_ONSET_3 = "vcpe/vcpe.onset.3.json";
84 private static final String VCPE_APPC_SUCCESS = "vcpe/vcpe.appc.success.json";
87 private static final String VDNS_TOSCA_COMPLIANT_POLICY = "vdns/tosca-compliant-vdns.json";
88 private static final String VDNS_TOSCA_COMPLIANT_RAINY_POLICY = "vdns/tosca-compliant-vdns-rainy.json";
89 private static final String VDNS_ONSET = "vdns/vdns.onset.json";
92 private static final String VFW_TOSCA_COMPLIANT_POLICY = "vfw/tosca-compliant-vfw.json";
93 private static final String VFW_TOSCA_COMPLIANT_TIME_OUT_POLICY = "vfw/tosca-compliant-timeout-vfw.json";
94 private static final String VFW_ONSET = "vfw/vfw.onset.json";
95 private static final String VFW_APPC_SUCCESS = "vfw/vfw.appc.success.json";
96 private static final String VFW_APPC_FAILURE = "vfw/vfw.appc.failure.json";
99 private static final String VPCI_TOSCA_COMPLIANT_POLICY = "vpci/tosca-compliant-vpci.json";
100 private static final String VPCI_ONSET = "vpci/vpci.onset.json";
101 private static final String VPCI_SDNR_SUCCESS = "vpci/vpci.sdnr.success.json";
104 private static final String VSONH_TOSCA_COMPLIANT_POLICY = "vsonh/tosca-compliant-vsonh.json";
105 private static final String VSONH_ONSET = "vsonh/vsonh.onset.json";
106 private static final String VSONH_SDNR_SUCCESS = "vsonh/vsonh.sdnr.success.json";
109 * Coders used to decode requests and responses.
111 protected static final Coder APPC_LEGACY_CODER = new StandardCoderInstantAsMillis();
112 protected static final Coder APPC_LCM_CODER = new StandardCoder();
113 protected static final Coder POLICY_CL_MGT_CODER = new PolicyClMgtCoder();
116 * Coders used to decode requests and responses.
118 private static final Coder SDNR_CODER = new StandardCoder();
120 // these may be overridden by junit tests
121 protected static Supplier<HttpClients> httpClientMaker = HttpClients::new;
122 protected static Supplier<Simulators> simMaker = Simulators::new;
123 protected static Supplier<Topics> topicMaker = Topics::new;
125 protected static Rules rules;
126 protected static HttpClients httpClients;
127 protected static Simulators simulators;
129 // used to inject and wait for messages
130 @Getter(AccessLevel.PROTECTED)
131 protected static Topics topics;
133 // used to wait for messages on SINK topics
134 protected Listener<VirtualControlLoopNotification> policyClMgt;
135 protected Listener<Request> appcClSink;
136 protected Listener<AppcLcmDmaapWrapper> appcLcmRead;
137 protected Listener<PciMessage> sdnrClSink;
140 * Tosca Policy that was loaded.
142 protected ToscaPolicy policy;
145 * Initializes {@link #rules}, {@link #httpClients}, and {@link #simulators}.
147 public static void initStatics() {
148 httpClients = httpClientMaker.get();
149 simulators = simMaker.get();
153 * Destroys {@link #httpClients}, {@link #simulators}, and {@link #rules}.
155 public static void finishStatics() {
156 httpClients.destroy();
157 simulators.destroy();
161 * Initializes {@link #topics} and {@link #controller}.
164 topics = topicMaker.get();
168 * Destroys {@link #topics} and resets the rule facts.
170 public void finish() {
174 // Service123 (i.e., Policy with multiple operations)
177 * Service123 with Tosca Compliant Policy.
180 public void testService123Compliant() {
181 policyClMgt = createNoficationTopicListener();
182 appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmDmaapWrapper.class, APPC_LCM_CODER);
183 policy = checkPolicy(SERVICE123_TOSCA_COMPLIANT_POLICY);
185 // inject an ONSET event over the DCAE topic
186 topics.inject(DCAE_TOPIC, SERVICE123_ONSET);
187 /* Wait to acquire a LOCK and a PDP-X PERMIT */
189 waitForLockAndPermit(policy, policyClMgt);
191 // restart request should be sent and fail four times (i.e., because retry=3)
192 for (int count = 0; count < 4; ++count) {
193 AppcLcmDmaapWrapper appcreq = appcLcmRead.await(req -> APPC_RESTART_OP.equals(req.getRpcName()));
195 topics.inject(APPC_LCM_WRITE_TOPIC, SERVICE123_APPC_RESTART_FAILURE,
196 appcreq.getBody().getInput().getCommonHeader().getSubRequestId());
198 // rebuild request should be sent and fail once
199 AppcLcmDmaapWrapper appcreq = appcLcmRead.await(req -> "rebuild".equals(req.getRpcName()));
200 topics.inject(APPC_LCM_WRITE_TOPIC, SERVICE123_APPC_REBUILD_FAILURE,
201 appcreq.getBody().getInput().getCommonHeader().getSubRequestId());
202 // migrate request should be sent and succeed
203 appcreq = appcLcmRead.await(req -> "migrate".equals(req.getRpcName()));
204 topics.inject(APPC_LCM_WRITE_TOPIC, SERVICE123_APPC_MIGRATE_SUCCESS,
205 appcreq.getBody().getInput().getCommonHeader().getSubRequestId());
206 /* --- Operation Completed --- */
207 waitForOperationSuccess();
208 /* --- Transaction Completed --- */
209 waitForFinalSuccess(policy, policyClMgt);
215 * This test case tests the scenario where 3 events occur and 2 of the requests refer
216 * to the same target entity while the 3rd is for another entity. The expected result
217 * is that the event with the duplicate target entity will have a final success result
218 * for one of the events, and a rejected message for the one that was unable to obtain
219 * the lock. The event that is referring to a different target entity should be able
220 * to obtain a lock since it is a different target. After processing of all events
221 * there should only be the policy and params objects left in memory.
224 public void testDuplicatesEvents() {
225 policyClMgt = createNoficationTopicListener();
226 appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmDmaapWrapper.class, APPC_LCM_CODER);
228 policy = checkPolicy(DUPLICATES_TOSCA_COMPLIANT_POLICY);
230 final long initCount = getCreateCount();
233 * Inject ONSET events over the DCAE topic. First and last have the same target
234 * entity, but different request IDs - only one should succeed. The middle one is
235 * for a different target entity, so it should succeed.
237 topics.inject(DCAE_TOPIC, DUPLICATES_ONSET_1, UUID.randomUUID().toString());
238 topics.inject(DCAE_TOPIC, DUPLICATES_ONSET_2);
239 topics.inject(DCAE_TOPIC, DUPLICATES_ONSET_1, UUID.randomUUID().toString());
241 // should see two restarts
242 for (int count = 0; count < 2; ++count) {
243 AppcLcmDmaapWrapper appcreq = appcLcmRead.await(req -> APPC_RESTART_OP.equals(req.getRpcName()));
246 topics.inject(APPC_LCM_WRITE_TOPIC, DUPLICATES_APPC_SUCCESS,
247 appcreq.getBody().getInput().getCommonHeader().getSubRequestId());
250 // should see two FINAL successes
251 VirtualControlLoopNotification notif1 = waitForFinalSuccess(policy, policyClMgt);
252 VirtualControlLoopNotification notif2 = waitForFinalSuccess(policy, policyClMgt);
254 // get the list of target names so we can ensure there's one of each
255 List<String> actual = List.of(notif1, notif2).stream().map(notif -> notif.getAai().get("generic-vnf.vnf-id"))
256 .sorted().collect(Collectors.toList());
258 assertEquals(List.of("duplicate-VNF", "vCPE_Infrastructure_vGMUX_demo_app").toString(), actual.toString());
260 long added = getCreateCount() - initCount;
261 assertEquals(2, added);
267 * Sunny Day with Tosca Compliant Policy.
270 public void testVcpeSunnyDayCompliant() {
271 appcLcmSunnyDay(VCPE_TOSCA_COMPLIANT_POLICY, VCPE_ONSET_1, APPC_RESTART_OP);
275 * An ONSET flood prevention test that injects a few ONSETs at once. It attempts to
276 * simulate the flooding behavior of the DCAE TCA microservice. TCA could blast tens
277 * or hundreds of ONSETs within sub-second intervals.
280 public void testVcpeOnsetFloodPrevention() {
281 appcLcmSunnyDay(VCPE_TOSCA_COMPLIANT_POLICY, List.of(VCPE_ONSET_1, VCPE_ONSET_2, VCPE_ONSET_3),
288 * Sunny Day with Tosca Compliant Policy.
291 public void testVdnsSunnyDayCompliant() {
292 httpSunnyDay(VDNS_TOSCA_COMPLIANT_POLICY, VDNS_ONSET);
296 * Vdns Rainy Day with Compliant Tosca Policy.
299 public void testVdnsRainyDayCompliant() {
300 httpRainyDay(VDNS_TOSCA_COMPLIANT_RAINY_POLICY, VDNS_ONSET);
307 * VFW Sunny Day with Tosca Compliant Policy.
310 public void testVfwSunnyDayCompliant() {
311 appcLegacySunnyDay(VFW_TOSCA_COMPLIANT_POLICY, VFW_ONSET, APPC_MODIFY_CONFIG_OP);
315 * VFW Rainy Day using compliant tosca policy (final failure).
318 public void testVfwRainyDayOverallTimeout() {
319 appcLegacyRainyDayNoResponse(VFW_TOSCA_COMPLIANT_TIME_OUT_POLICY, VFW_ONSET, APPC_MODIFY_CONFIG_OP);
323 * VFW Rainy day using compliant tosca policy (final failure due to timeout).
326 public void testVfwRainyDayCompliantTimeout() {
327 appcLegacyRainyDayNoResponse(VFW_TOSCA_COMPLIANT_POLICY, VFW_ONSET, APPC_MODIFY_CONFIG_OP);
331 * VPCI Sunny Day Tosca Policy.
334 public void testVpciSunnyDayCompliant() {
335 sdnrSunnyDay(VPCI_TOSCA_COMPLIANT_POLICY, VPCI_ONSET, VPCI_SDNR_SUCCESS, "ModifyConfig");
341 * VSONH Sunny Day with Tosca Policy.
344 public void testVsonhSunnyDayCompliant() {
345 sdnrSunnyDay(VSONH_TOSCA_COMPLIANT_POLICY, VSONH_ONSET, VSONH_SDNR_SUCCESS, "ModifyConfigANR");
349 * Sunny day scenario for use cases that use APPC-LCM.
351 * @param policyFile file containing the ToscaPolicy to be loaded
352 * @param onsetFile file containing the ONSET to be injected
353 * @param operation expected APPC operation request
355 protected void appcLcmSunnyDay(String policyFile, String onsetFile, String operation) {
356 appcLcmSunnyDay(policyFile, List.of(onsetFile), operation);
360 * Sunny day scenario for use cases that use APPC-LCM.
362 * @param policyFile file containing the ToscaPolicy to be loaded
363 * @param onsetFiles list of files containing the ONSET to be injected
364 * @param operation expected APPC operation request
366 protected void appcLcmSunnyDay(String policyFile, List<String> onsetFiles, String operation) {
367 policyClMgt = createNoficationTopicListener();
368 appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmDmaapWrapper.class, APPC_LCM_CODER);
370 policy = checkPolicy(policyFile);
373 // inject several ONSET events over the DCAE topic
374 for (String onsetFile : onsetFiles) {
375 topics.inject(DCAE_TOPIC, onsetFile);
378 /* Wait to acquire a LOCK and a PDP-X PERMIT */
379 waitForLockAndPermit(policy, policyClMgt);
382 * Ensure that an APPC RESTART request was sent in response to the matching ONSET
384 AppcLcmDmaapWrapper appcreq = appcLcmRead.await(req -> operation.equals(req.getRpcName()));
387 * Inject a 400 APPC Response Return over the APPC topic, with appropriate
390 topics.inject(APPC_LCM_WRITE_TOPIC, VCPE_APPC_SUCCESS,
391 appcreq.getBody().getInput().getCommonHeader().getSubRequestId());
393 /* --- Operation Completed --- */
395 waitForOperationSuccess();
397 /* --- Transaction Completed --- */
398 waitForFinalSuccess(policy, policyClMgt);
402 * Sunny day scenario for use cases that use Legacy APPC.
404 * @param policyFile file containing the ToscaPolicy to be loaded
405 * @param onsetFile file containing the ONSET to be injected
406 * @param operation expected APPC operation request
408 protected void appcLegacySunnyDay(String policyFile, String onsetFile, String operation) {
409 policyClMgt = createNoficationTopicListener();
410 appcClSink = topics.createListener(APPC_CL_TOPIC, Request.class, APPC_LEGACY_CODER);
412 policy = checkPolicy(policyFile);
414 /* Inject an ONSET event over the DCAE topic */
415 topics.inject(DCAE_TOPIC, onsetFile);
417 /* Wait to acquire a LOCK and a PDP-X PERMIT */
418 waitForLockAndPermit(policy, policyClMgt);
421 * Ensure that an APPC RESTART request was sent in response to the matching ONSET
423 Request appcreq = appcClSink.await(req -> operation.equals(req.getAction()));
426 * Inject a 400 APPC Response Return over the APPC topic, with appropriate
429 topics.inject(APPC_CL_TOPIC, VFW_APPC_SUCCESS, appcreq.getCommonHeader().getSubRequestId());
431 /* --- Operation Completed --- */
433 waitForOperationSuccess();
435 /* --- Transaction Completed --- */
436 waitForFinalSuccess(policy, policyClMgt);
440 * Rainy day scenario for use cases that use Legacy APPC.
442 * @param policyFile file containing the ToscaPolicy to be loaded
443 * @param onsetFile file containing the ONSET to be injected
444 * @param operation expected APPC operation request
445 * @param checkOperation flag to determine whether or not to wait for operation timeout
447 protected void appcLegacyRainyDay(String policyFile, String onsetFile, String operation) {
448 policyClMgt = createNoficationTopicListener();
449 appcClSink = topics.createListener(APPC_CL_TOPIC, Request.class, APPC_LEGACY_CODER);
451 policy = checkPolicy(policyFile);
453 /* Inject an ONSET event over the DCAE topic */
454 topics.inject(DCAE_TOPIC, onsetFile);
456 /* Wait to acquire a LOCK and a PDP-X PERMIT */
457 waitForLockAndPermit(policy, policyClMgt);
460 * Ensure that an APPC RESTART request was sent in response to the matching ONSET
462 Request appcreq = appcClSink.await(req -> operation.equals(req.getAction()));
465 * Inject a 401 APPC Response Return over the APPC topic, with appropriate
468 topics.inject(APPC_CL_TOPIC, VFW_APPC_FAILURE, appcreq.getCommonHeader().getSubRequestId());
470 /* --- Operation Completed --- */
471 waitForOperationFailure();
473 /* --- Transaction Completed --- */
474 waitForFinalFailure(policy, policyClMgt);
478 * Rainy day scenario for use cases that use Legacy APPC.
479 * Expected to fail due to timeout.
481 * @param policyFile file containing the ToscaPolicy to be loaded
482 * @param onsetFile file containing the ONSET to be injected
483 * @param operation expected APPC operation request
485 protected void appcLegacyRainyDayNoResponse(String policyFile, String onsetFile, String operation) {
486 policyClMgt = createNoficationTopicListener();
487 appcClSink = topics.createListener(APPC_CL_TOPIC, Request.class, APPC_LEGACY_CODER);
489 policy = checkPolicy(policyFile);
491 /* Inject an ONSET event over the DCAE topic */
492 topics.inject(DCAE_TOPIC, onsetFile);
494 /* Wait to acquire a LOCK and a PDP-X PERMIT */
495 waitForLockAndPermit(policy, policyClMgt);
498 * Ensure that an APPC RESTART request was sent in response to the matching ONSET
500 appcClSink.await(req -> operation.equals(req.getAction()));
503 * Do not inject an APPC Response.
506 /* --- Transaction Completed --- */
507 waitForFinalFailure(policy, policyClMgt);
511 * Sunny day scenario for use cases that use SDNR.
513 * @param policyFile file containing the ToscaPolicy to be loaded
514 * @param onsetFile file containing the ONSET to be injected
515 * @param operation expected SDNR operation request
517 protected void sdnrSunnyDay(String policyFile, String onsetFile, String successFile, String operation) {
518 policyClMgt = createNoficationTopicListener();
519 sdnrClSink = topics.createListener(SDNR_CL_TOPIC, PciMessage.class, SDNR_CODER);
521 policy = checkPolicy(policyFile);
523 /* Inject an ONSET event over the DCAE topic */
524 topics.inject(DCAE_TOPIC, onsetFile);
526 /* Wait to acquire a LOCK and a PDP-X PERMIT */
527 waitForLockAndPermit(policy, policyClMgt);
530 * Ensure that an SDNR RESTART request was sent in response to the matching ONSET
532 PciMessage pcireq = sdnrClSink.await(req -> operation.equals(req.getBody().getInput().getAction()));
537 topics.inject(SDNR_CL_RSP_TOPIC, successFile, pcireq.getBody().getInput().getCommonHeader().getSubRequestId());
539 /* --- Operation Completed --- */
541 waitForOperationSuccess();
543 /* --- Transaction Completed --- */
544 waitForFinalSuccess(policy, policyClMgt);
548 * Sunny day scenario for use cases that use an HTTP simulator.
550 * @param policyFile file containing the ToscaPolicy to be loaded
551 * @param onsetFile file containing the ONSET to be injected
552 * @param operation expected APPC operation request
554 protected void httpSunnyDay(String policyFile, String onsetFile) {
555 policyClMgt = createNoficationTopicListener();
557 policy = checkPolicy(policyFile);
559 /* Inject an ONSET event over the DCAE topic */
560 topics.inject(DCAE_TOPIC, onsetFile);
562 /* Wait to acquire a LOCK and a PDP-X PERMIT */
563 waitForLockAndPermit(policy, policyClMgt);
565 /* --- Operation Completed --- */
567 waitForOperationSuccess();
569 /* --- Transaction Completed --- */
570 waitForFinalSuccess(policy, policyClMgt);
574 * Rainy day scenario for use cases that use an HTTP simulator.
576 * @param policyFile file containing the ToscaPolicy to be loaded
577 * @param onsetFile file containing the ONSET to be injected
578 * @param operation expected APPC operation request
580 protected void httpRainyDay(String policyFile, String onsetFile) {
581 policyClMgt = createNoficationTopicListener();
583 policy = checkPolicy(policyFile);
585 /* Inject an ONSET event over the DCAE topic */
586 topics.inject(DCAE_TOPIC, onsetFile);
588 /* Wait to acquire a LOCK and a PDP-X PERMIT */
589 waitForLockAndPermit(policy, policyClMgt);
591 /* --- Operation Completed --- */
592 waitForOperationFailure();
594 /* --- Transaction Completed --- */
595 waitForFinalFailure(policy, policyClMgt);
598 protected long getCreateCount() {
599 return ControlLoopEventManager2.getCreateCount();
603 * Waits for a OPERATION SUCCESS transaction notification.
605 protected void waitForOperationSuccess() {
606 policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION_SUCCESS);
610 * Waits for a FINAL SUCCESS transaction notification.
612 * @return the FINAL SUCCESS notification
614 protected VirtualControlLoopNotification waitForFinalSuccess(ToscaPolicy policy,
615 Listener<VirtualControlLoopNotification> policyClMgt) {
617 return this.waitForFinal(policy, policyClMgt, ControlLoopNotificationType.FINAL_SUCCESS);
621 * Waits for a OPERATION FAILURE transaction notification.
623 protected void waitForOperationFailure() {
624 policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION_FAILURE);
628 * Waits for a FINAL FAILURE transaction notification.
630 * @return the FINAL FAILURE notification
632 protected VirtualControlLoopNotification waitForFinalFailure(ToscaPolicy policy,
633 Listener<VirtualControlLoopNotification> policyClMgt) {
635 return this.waitForFinal(policy, policyClMgt, ControlLoopNotificationType.FINAL_FAILURE);
639 * Waits for notifications for LOCK acquisition and GUARD Permit so that event
640 * processing may proceed.
642 protected abstract void waitForLockAndPermit(ToscaPolicy policy,
643 Listener<VirtualControlLoopNotification> policyClMgt);
646 * Waits for a FINAL transaction notification.
648 * @param finalType FINAL_xxx type for which to wait
650 * @return the FINAL notification
652 protected abstract VirtualControlLoopNotification waitForFinal(ToscaPolicy policy,
653 Listener<VirtualControlLoopNotification> policyClMgt, ControlLoopNotificationType finalType);
656 * Returns ToscaPolicy from File.
658 * @param fileName a path name
659 * @return ToscaPolicy
661 protected ToscaPolicy checkPolicy(String fileName) {
663 return Rules.getPolicyFromFile(fileName);
664 } catch (CoderException e) {
665 throw new IllegalArgumentException(fileName, e);
670 * Creates a Coder for PolicyClMgt from StandardCoder.
673 public static class PolicyClMgtCoder extends StandardCoder {
674 public PolicyClMgtCoder() {
675 super(org.onap.policy.controlloop.util.Serialization.gson,
676 org.onap.policy.controlloop.util.Serialization.gsonPretty);
681 * Returns Listener from createListner based on Coder.
682 * @return the Listener
684 protected Listener<VirtualControlLoopNotification> createNoficationTopicListener() {
685 return topics.createListener(POLICY_CL_MGT_TOPIC,
686 VirtualControlLoopNotification.class, POLICY_CL_MGT_CODER);