f917fcf487b6b2fb756338d19e429e20ebe4361e
[policy/apex-pdp.git] / services / services-engine / src / test / java / org / onap / policy / apex / service / engine / engdep / DummyEngineService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2020 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.service.engine.engdep;
23
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27
28 import org.apache.commons.lang3.NotImplementedException;
29 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
30 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
31 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
32 import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
33 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
34 import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
35 import org.onap.policy.apex.service.engine.runtime.EngineService;
36 import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
37
38 /**
39  * A dummy engine service class.
40  */
41 public class DummyEngineService implements EngineService {
42
43     private AxArtifactKey startEngineKey;
44     private AxArtifactKey stopEngineKey;
45     private long periodicPeriod;
46     private AxArtifactKey statusKey;
47     private AxArtifactKey runtimeInfoKey;
48     private int modelKeyGetCalled;
49     private AxArtifactKey updateModelKey;
50
51     /**
52      * {@inheritDoc}.
53      */
54     @Override
55     public void registerActionListener(String listenerName, ApexEventListener listener) {
56         throw new NotImplementedException("Not implemented on dummy class");
57     }
58
59     /**
60      * {@inheritDoc}.
61      */
62     @Override
63     public void deregisterActionListener(String listenerName) {
64         throw new NotImplementedException("Not implemented on dummy class");
65     }
66
67     /**
68      * {@inheritDoc}.
69      */
70     @Override
71     public EngineServiceEventInterface getEngineServiceEventInterface() {
72         throw new NotImplementedException("Not implemented on dummy class");
73     }
74
75     /**
76      * {@inheritDoc}.
77      */
78     @Override
79     public AxArtifactKey getKey() {
80         return new AxArtifactKey("DummyEngineService:0.0.1");
81     }
82
83     /**
84      * {@inheritDoc}.
85      */
86     @Override
87     public Collection<AxArtifactKey> getEngineKeys() {
88         List<AxArtifactKey> keys = new ArrayList<>();
89         keys.add(new AxArtifactKey("DummyEngineService:0.0.1"));
90         return keys;
91     }
92
93     /**
94      * {@inheritDoc}.
95      */
96     @Override
97     public AxArtifactKey getApexModelKey() {
98         modelKeyGetCalled++;
99
100         return new AxArtifactKey("DummyApexModelKey:0.0.1");
101     }
102
103     /**
104      * {@inheritDoc}.
105      */
106     @Override
107     public void updateModel(AxArtifactKey engineServiceKey, String apexModelString, boolean forceFlag)
108                     throws ApexException {
109         updateModelKey = engineServiceKey;
110     }
111
112     /**
113      * {@inheritDoc}.
114      */
115     @Override
116     public void updateModel(AxArtifactKey engineServiceKey, AxPolicyModel apexModel, boolean forceFlag)
117                     throws ApexException {
118         throw new NotImplementedException("Not implemented on dummy class");
119     }
120
121     /**
122      * {@inheritDoc}.
123      */
124     @Override
125     public AxEngineState getState() {
126         throw new NotImplementedException("Not implemented on dummy class");
127     }
128
129     /**
130      * {@inheritDoc}.
131      */
132     @Override
133     public List<AxEngineModel> getEngineStats() {
134         throw new NotImplementedException("Not implemented on dummy class");
135     }
136
137     /**
138      * {@inheritDoc}.
139      */
140     @Override
141     public void startAll() throws ApexException {
142         throw new NotImplementedException("Not implemented on dummy class");
143     }
144
145     /**
146      * {@inheritDoc}.
147      */
148     @Override
149     public void start(AxArtifactKey engineKey) throws ApexException {
150         startEngineKey = engineKey;
151     }
152
153     /**
154      * {@inheritDoc}.
155      */
156     @Override
157     public void stop() throws ApexException {
158     }
159
160     /**
161      * {@inheritDoc}.
162      */
163     @Override
164     public void stop(AxArtifactKey engineKey) throws ApexException {
165         stopEngineKey = engineKey;
166     }
167
168     /**
169      * {@inheritDoc}.
170      */
171     @Override
172     public void clear() throws ApexException {
173         throw new NotImplementedException("Not implemented on dummy class");
174     }
175
176     /**
177      * {@inheritDoc}.
178      */
179     @Override
180     public void clear(AxArtifactKey engineKey) throws ApexException {
181         throw new NotImplementedException("Not implemented on dummy class");
182     }
183
184     /**
185      * {@inheritDoc}.
186      */
187     @Override
188     public boolean isStarted() {
189         throw new NotImplementedException("Not implemented on dummy class");
190     }
191
192     /**
193      * {@inheritDoc}.
194      */
195     @Override
196     public boolean isStarted(AxArtifactKey engineKey) {
197         throw new NotImplementedException("Not implemented on dummy class");
198     }
199
200     /**
201      * {@inheritDoc}.
202      */
203     @Override
204     public boolean isStopped() {
205         throw new NotImplementedException("Not implemented on dummy class");
206     }
207
208     /**
209      * {@inheritDoc}.
210      */
211     @Override
212     public boolean isStopped(AxArtifactKey engineKey) {
213         throw new NotImplementedException("Not implemented on dummy class");
214     }
215
216     /**
217      * {@inheritDoc}.
218      */
219     @Override
220     public void startPeriodicEvents(long period) throws ApexException {
221         periodicPeriod = period;
222     }
223
224     /**
225      * {@inheritDoc}.
226      */
227     @Override
228     public void stopPeriodicEvents() throws ApexException {
229         periodicPeriod = 0;
230     }
231
232     /**
233      * {@inheritDoc}.
234      */
235     @Override
236     public String getStatus(AxArtifactKey engineKey) throws ApexException {
237         statusKey = engineKey;
238         return "The Status";
239     }
240
241     /**
242      * {@inheritDoc}.
243      */
244     @Override
245     public String getRuntimeInfo(AxArtifactKey engineKey) throws ApexException {
246         runtimeInfoKey = engineKey;
247         return "The Runtime Info";
248     }
249
250     public AxArtifactKey getStartEngineKey() {
251         return startEngineKey;
252     }
253
254     public AxArtifactKey getStopEngineKey() {
255         return stopEngineKey;
256     }
257
258     public long getPeriodicPeriod() {
259         return periodicPeriod;
260     }
261
262     public AxArtifactKey getStatusKey() {
263         return statusKey;
264     }
265
266     public AxArtifactKey getRuntimeInfoKey() {
267         return runtimeInfoKey;
268     }
269
270     public int getModelKeyGetCalled() {
271         return modelKeyGetCalled;
272     }
273
274     public AxArtifactKey getUpdateModelKey() {
275         return updateModelKey;
276     }
277 }