2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2020 Nordix Foundation.
5 * Modifications Copyright (C) 2021 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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.apex.examples.myfirstpolicy;
25 import static org.awaitility.Awaitility.await;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.concurrent.TimeUnit;
30 import lombok.AllArgsConstructor;
32 import org.onap.policy.apex.core.engine.engine.EnEventListener;
33 import org.onap.policy.apex.core.engine.event.EnEvent;
36 * The listener interface for receiving SaleAuth events. The class that is interested in processing a SaleAuth event
37 * implements this interface, and the object created with that class is registered with a component using the
38 * component's <code>addTestApexActionListener</code> method. When the testApexAction event occurs, that object's
39 * appropriate method is invoked.
41 * @author Liam Fallon (liam.fallon@ericsson.com)
44 public class TestSaleAuthListener implements EnEventListener {
45 // CHECKSTYLE:OFF: MagicNumber
47 private final List<EnEvent> resultEvents = new ArrayList<>();
50 private final String id;
57 public EnEvent getResult() {
58 await().atMost(200, TimeUnit.MILLISECONDS).until(() -> !resultEvents.isEmpty());
59 return resultEvents.remove(0);
66 public void onEnEvent(final EnEvent saleauthEvent) {
67 if (saleauthEvent != null) {
68 System.out.println("SaleAuth event from engine:" + saleauthEvent.getName());
69 resultEvents.add(saleauthEvent);