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;
23 import org.junit.After;
24 import org.junit.AfterClass;
25 import org.junit.Before;
26 import org.junit.BeforeClass;
27 import org.junit.runner.RunWith;
28 import org.onap.policy.controlloop.common.rules.test.DroolsRuleTest;
29 import org.onap.policy.controlloop.common.rules.test.Listener;
30 import org.onap.policy.controlloop.common.rules.test.NamedRunner;
31 import org.onap.policy.controlloop.common.rules.test.TestNames;
32 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
33 import org.onap.policy.simulators.Util;
36 * Tests use cases using Frankfurt rules.
39 * Note: this runs ALL tests (i.e., any whose names start with "test").
41 @RunWith(NamedRunner.class)
42 @TestNames(prefixes = {"test"})
44 public class FrankfurtTest extends DroolsRuleTest {
45 protected static final String CONTROLLER_NAME = "frankfurt";
52 public static void setUpBeforeClass() {
53 initStatics(CONTROLLER_NAME);
55 rules.configure("src/main/resources");
57 httpClients.addClients("frankfurt");
58 simulators.start(Util::buildAaiSim, Util::buildSoSim, Util::buildVfcSim, Util::buildGuardSim,
66 public static void tearDownAfterClass() {
82 public void tearDown() {
87 protected void waitForLockAndPermit(ToscaPolicy policy, Listener<VirtualControlLoopNotification> policyClMgt) {
88 String policyName = policy.getIdentifier().getName();
90 policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.ACTIVE
91 && (policyName + ".EVENT").equals(notif.getPolicyName()));
93 policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION
94 && (policyName + ".EVENT.MANAGER.PROCESSING").equals(notif.getPolicyName())
95 && notif.getMessage().startsWith("Sending guard query"));
97 policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION
98 && (policyName + ".EVENT.MANAGER.PROCESSING").equals(notif.getPolicyName())
99 && notif.getMessage().startsWith("Guard result") && notif.getMessage().endsWith("Permit"));
101 policyClMgt.await(notif -> notif.getNotification() == ControlLoopNotificationType.OPERATION
102 && (policyName + ".EVENT.MANAGER.PROCESSING").equals(notif.getPolicyName())
103 && notif.getMessage().startsWith("actor="));
107 protected VirtualControlLoopNotification waitForFinal(ToscaPolicy policy,
108 Listener<VirtualControlLoopNotification> policyClMgt, ControlLoopNotificationType finalType) {
110 return policyClMgt.await(notif -> notif.getNotification() == finalType
111 && (policy.getIdentifier().getName() + ".EVENT.MANAGER.FINAL").equals(notif.getPolicyName()));