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