2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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.vid.config;
23 import org.hibernate.SessionFactory;
24 import org.mockito.Mockito;
25 import org.onap.portalsdk.core.service.DataAccessService;
26 import org.onap.vid.aai.AaiClientInterface;
27 import org.onap.vid.aai.util.HttpsAuthClient;
28 import org.onap.vid.aai.util.SSLContextProvider;
29 import org.onap.vid.aai.util.ServletRequestHelper;
30 import org.onap.vid.aai.util.SystemPropertyHelper;
31 import org.onap.vid.dal.AsyncInstantiationRepository;
32 import org.onap.vid.job.JobAdapter;
33 import org.onap.vid.job.JobsBrokerService;
34 import org.onap.vid.job.command.ALaCarteServiceCommand;
35 import org.onap.vid.job.command.CommandUtils;
36 import org.onap.vid.job.command.InProgressStatusService;
37 import org.onap.vid.job.command.InstanceGroupCommand;
38 import org.onap.vid.job.command.InstanceGroupMemberCommand;
39 import org.onap.vid.job.command.JobCommandFactory;
40 import org.onap.vid.job.command.MacroServiceCommand;
41 import org.onap.vid.job.command.MsoRequestBuilder;
42 import org.onap.vid.job.command.MsoResultHandlerService;
43 import org.onap.vid.job.command.NetworkCommand;
44 import org.onap.vid.job.command.VfmoduleCommand;
45 import org.onap.vid.job.command.VnfCommand;
46 import org.onap.vid.job.command.VolumeGroupCommand;
47 import org.onap.vid.job.command.WatchChildrenJobsBL;
48 import org.onap.vid.job.impl.JobAdapterImpl;
49 import org.onap.vid.job.impl.JobWorker;
50 import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
51 import org.onap.vid.model.ModelUtil;
52 import org.onap.vid.mso.RestMsoImplementation;
53 import org.onap.vid.services.AsyncInstantiationBusinessLogic;
54 import org.onap.vid.services.AsyncInstantiationBusinessLogicImpl;
55 import org.onap.vid.services.AuditService;
56 import org.onap.vid.services.AuditServiceImpl;
57 import org.onap.vid.services.CloudOwnerService;
58 import org.onap.vid.services.InstantiationTemplatesService;
59 import org.onap.vid.services.VersionService;
60 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
61 import org.springframework.context.ApplicationContext;
62 import org.springframework.context.annotation.Bean;
63 import org.springframework.context.annotation.Configuration;
64 import org.springframework.context.annotation.Scope;
65 import org.togglz.core.manager.FeatureManager;
68 public class JobCommandsConfigWithMockedMso {
71 public RestMsoImplementation restMso() {
72 return Mockito.mock(RestMsoImplementation.class);
76 public VersionService versionService() {
77 return Mockito.mock(VersionService.class);
81 public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory, VersionService versionService) {
82 return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0,versionService);
86 public SSLContextProvider sslContextProvider() {
87 return new SSLContextProvider();
91 public SystemPropertyHelper systemPropertyHelper() {
92 return new SystemPropertyHelper();
96 public ServletRequestHelper servletRequestHelper() {
97 return new ServletRequestHelper();
101 public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){
102 return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
107 public JobAdapter jobAdapter(FeatureManager featureManager) {
108 return new JobAdapterImpl(featureManager);
112 public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
113 return new JobCommandFactory(applicationContext);
117 public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
118 JobWorker jobWorker = new JobWorker();
119 jobWorker.setJobsBrokerService(jobsBrokerService);
120 jobWorker.setJobCommandFactory(jobCommandFactory);
125 public FeatureManager featureManager() {
126 return Mockito.mock(FeatureManager.class);
130 public MsoRequestBuilder msoRequestHandlerService(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
131 CloudOwnerService cloudOwnerService,
132 AaiClientInterface aaiClient,
133 FeatureManager featureManager) {
134 return new MsoRequestBuilder(asyncInstantiationBusinessLogic, cloudOwnerService, aaiClient, featureManager);
137 public AsyncInstantiationRepository asyncInstantiationRepository(DataAccessService dataAccessService) {
138 return new AsyncInstantiationRepository(dataAccessService);
142 public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(JobAdapter jobAdapter,
143 JobsBrokerService jobsBrokerService,
144 SessionFactory sessionFactory,
145 AaiClientInterface aaiClient,
146 FeatureManager featureManager,
147 CloudOwnerService cloudOwnerService,
148 AsyncInstantiationRepository asyncInstantiationRepository,
149 AuditService auditService) {
150 return new AsyncInstantiationBusinessLogicImpl(jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService, asyncInstantiationRepository, auditService);
154 public ModelUtil modelUtil() {return new ModelUtil();}
157 public InstantiationTemplatesService instantiationTemplatesService(
159 AsyncInstantiationRepository asyncInstantiationRepository,
160 FeatureManager featureManager
162 return new InstantiationTemplatesService(modelUtil, asyncInstantiationRepository, featureManager);
167 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
168 public ALaCarteServiceCommand aLaCarteServiceCommand(
169 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
170 JobsBrokerService jobsBrokerService,
171 MsoRequestBuilder msoRequestBuilder,
172 MsoResultHandlerService msoResultHandlerService,
173 JobAdapter jobAdapter,
174 InProgressStatusService inProgressStatusService,
175 WatchChildrenJobsBL watchChildrenJobsBL,
176 RestMsoImplementation restMso,
177 AuditService auditService) {
178 return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService);
182 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
183 public MacroServiceCommand macroServiceCommand(
184 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
185 JobsBrokerService jobsBrokerService,
186 MsoRequestBuilder msoRequestBuilder,
187 MsoResultHandlerService msoResultHandlerService,
188 JobAdapter jobAdapter,
189 InProgressStatusService inProgressStatusService,
190 WatchChildrenJobsBL watchChildrenJobsBL,
191 RestMsoImplementation restMso,
192 AuditService auditService) {
193 return new MacroServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService);
198 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
199 public NetworkCommand networkCommand(
200 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
201 RestMsoImplementation restMso,
202 MsoRequestBuilder msoRequestBuilder,
203 MsoResultHandlerService msoResultHandlerService,
204 InProgressStatusService inProgressStatusService,
205 WatchChildrenJobsBL watchChildrenJobsBL,
206 JobsBrokerService jobsBrokerService,
207 JobAdapter jobAdapter) {
208 return new NetworkCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
209 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
212 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
213 public InstanceGroupCommand instanceGroupCommand(
214 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
215 MsoRequestBuilder msoRequestBuilder,
216 MsoResultHandlerService msoResultHandlerService,
217 InProgressStatusService inProgressStatusService,
218 WatchChildrenJobsBL watchChildrenJobsBL,
219 RestMsoImplementation restMso,
220 JobsBrokerService jobsBrokerService,
221 JobAdapter jobAdapter) {
222 return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
226 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
227 public InstanceGroupMemberCommand instanceGroupMemberCommand (
228 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
229 MsoRequestBuilder msoRequestBuilder,
230 MsoResultHandlerService msoResultHandlerService,
231 InProgressStatusService inProgressStatusService,
232 WatchChildrenJobsBL watchChildrenJobsBL,
233 RestMsoImplementation restMso,
234 JobsBrokerService jobsBrokerService,
235 JobAdapter jobAdapter) {
236 return new InstanceGroupMemberCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService,
237 watchChildrenJobsBL, jobsBrokerService, jobAdapter);
242 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
243 public VnfCommand VnfCommand(
244 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
245 RestMsoImplementation restMso,
246 MsoRequestBuilder msoRequestBuilder,
247 MsoResultHandlerService msoResultHandlerService,
248 InProgressStatusService inProgressStatusService,
249 WatchChildrenJobsBL watchChildrenJobsBL,
250 JobsBrokerService jobsBrokerService,
251 JobAdapter jobAdapter,
252 FeatureManager featureManager) {
253 return new VnfCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
254 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter,
259 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
260 public VolumeGroupCommand volumeGroupCommand(
261 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
262 RestMsoImplementation restMso,
263 MsoRequestBuilder msoRequestBuilder,
264 MsoResultHandlerService msoResultHandlerService,
265 InProgressStatusService inProgressStatusService,
266 WatchChildrenJobsBL watchChildrenJobsBL,
267 JobsBrokerService jobsBrokerService,
268 JobAdapter jobAdapter) {
269 return new VolumeGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
270 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter);
274 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
275 public VfmoduleCommand VfmoduleCommand(
276 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
277 RestMsoImplementation restMso,
278 MsoRequestBuilder msoRequestBuilder,
279 MsoResultHandlerService msoResultHandlerService,
280 InProgressStatusService inProgressStatusService,
281 WatchChildrenJobsBL watchChildrenJobsBL,
282 JobsBrokerService jobsBrokerService,
283 JobAdapter jobAdapter) {
284 return new VfmoduleCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
285 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
288 public AuditService auditService(RestMsoImplementation msoClient, AsyncInstantiationRepository asyncInstantiationRepository) {
289 return new AuditServiceImpl(msoClient, asyncInstantiationRepository);
293 public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService, FeatureManager featureManager) {
294 return new InProgressStatusService(asyncInstantiationBL, restMso, auditService, featureManager);
298 public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) {
299 return new MsoResultHandlerService(asyncInstantiationBL, auditService);
303 public CommandUtils commandUtils() {
304 return Mockito.mock(CommandUtils.class);
308 public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) {
309 return new WatchChildrenJobsBL(dataAccessService);