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.*;
35 import org.onap.vid.job.impl.JobAdapterImpl;
36 import org.onap.vid.job.impl.JobWorker;
37 import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
38 import org.onap.vid.mso.RestMsoImplementation;
39 import org.onap.vid.services.*;
40 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
41 import org.springframework.context.ApplicationContext;
42 import org.springframework.context.annotation.Bean;
43 import org.springframework.context.annotation.Configuration;
44 import org.springframework.context.annotation.Scope;
45 import org.togglz.core.manager.FeatureManager;
48 public class JobCommandsConfigWithMockedMso {
51 public RestMsoImplementation restMso() {
52 return Mockito.mock(RestMsoImplementation.class);
56 public VersionService versionService() {
57 return Mockito.mock(VersionService.class);
61 public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory, VersionService versionService) {
62 return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0,versionService);
66 public SSLContextProvider sslContextProvider() {
67 return new SSLContextProvider();
71 public SystemPropertyHelper systemPropertyHelper() {
72 return new SystemPropertyHelper();
76 public ServletRequestHelper servletRequestHelper() {
77 return new ServletRequestHelper();
81 public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){
82 return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
87 public JobAdapter jobAdapter(FeatureManager featureManager) {
88 return new JobAdapterImpl(featureManager);
92 public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
93 return new JobCommandFactory(applicationContext);
97 public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
98 JobWorker jobWorker = new JobWorker();
99 jobWorker.setJobsBrokerService(jobsBrokerService);
100 jobWorker.setJobCommandFactory(jobCommandFactory);
105 public FeatureManager featureManager() {
106 return Mockito.mock(FeatureManager.class);
110 public MsoRequestBuilder msoRequestHandlerService(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
111 CloudOwnerService cloudOwnerService,
112 AaiClientInterface aaiClient,
113 FeatureManager featureManager) {
114 return new MsoRequestBuilder(asyncInstantiationBusinessLogic, cloudOwnerService, aaiClient, featureManager);
117 public AsyncInstantiationRepository asyncInstantiationRepository(DataAccessService dataAccessService) {
118 return new AsyncInstantiationRepository(dataAccessService);
122 public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(JobAdapter jobAdapter,
123 JobsBrokerService jobsBrokerService,
124 SessionFactory sessionFactory,
125 AaiClientInterface aaiClient,
126 FeatureManager featureManager,
127 CloudOwnerService cloudOwnerService,
128 AsyncInstantiationRepository asyncInstantiationRepository,
129 AuditService auditService) {
130 return new AsyncInstantiationBusinessLogicImpl(jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService, asyncInstantiationRepository, auditService);
135 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
136 public ALaCarteServiceCommand aLaCarteServiceCommand(
137 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
138 JobsBrokerService jobsBrokerService,
139 MsoRequestBuilder msoRequestBuilder,
140 MsoResultHandlerService msoResultHandlerService,
141 JobAdapter jobAdapter,
142 InProgressStatusService inProgressStatusService,
143 WatchChildrenJobsBL watchChildrenJobsBL,
144 RestMsoImplementation restMso,
145 AuditService auditService) {
146 return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService);
150 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
151 public MacroServiceCommand macroServiceCommand(
152 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
153 JobsBrokerService jobsBrokerService,
154 MsoRequestBuilder msoRequestBuilder,
155 MsoResultHandlerService msoResultHandlerService,
156 JobAdapter jobAdapter,
157 InProgressStatusService inProgressStatusService,
158 WatchChildrenJobsBL watchChildrenJobsBL,
159 RestMsoImplementation restMso,
160 AuditService auditService) {
161 return new MacroServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService);
166 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
167 public NetworkCommand networkCommand(
168 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
169 RestMsoImplementation restMso,
170 MsoRequestBuilder msoRequestBuilder,
171 MsoResultHandlerService msoResultHandlerService,
172 InProgressStatusService inProgressStatusService,
173 WatchChildrenJobsBL watchChildrenJobsBL,
174 JobsBrokerService jobsBrokerService,
175 JobAdapter jobAdapter) {
176 return new NetworkCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
177 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
180 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
181 public InstanceGroupCommand instanceGroupCommand(
182 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
183 MsoRequestBuilder msoRequestBuilder,
184 MsoResultHandlerService msoResultHandlerService,
185 InProgressStatusService inProgressStatusService,
186 WatchChildrenJobsBL watchChildrenJobsBL,
187 RestMsoImplementation restMso,
188 JobsBrokerService jobsBrokerService,
189 JobAdapter jobAdapter) {
190 return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
194 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
195 public InstanceGroupMemberCommand instanceGroupMemberCommand (
196 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
197 MsoRequestBuilder msoRequestBuilder,
198 MsoResultHandlerService msoResultHandlerService,
199 InProgressStatusService inProgressStatusService,
200 WatchChildrenJobsBL watchChildrenJobsBL,
201 RestMsoImplementation restMso,
202 JobsBrokerService jobsBrokerService,
203 JobAdapter jobAdapter) {
204 return new InstanceGroupMemberCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService,
205 watchChildrenJobsBL, jobsBrokerService, jobAdapter);
210 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
211 public VnfCommand VnfCommand(
212 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
213 RestMsoImplementation restMso,
214 MsoRequestBuilder msoRequestBuilder,
215 MsoResultHandlerService msoResultHandlerService,
216 InProgressStatusService inProgressStatusService,
217 WatchChildrenJobsBL watchChildrenJobsBL,
218 JobsBrokerService jobsBrokerService,
219 JobAdapter jobAdapter,
220 FeatureManager featureManager) {
221 return new VnfCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
222 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter,
227 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
228 public VolumeGroupCommand volumeGroupCommand(
229 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
230 RestMsoImplementation restMso,
231 MsoRequestBuilder msoRequestBuilder,
232 MsoResultHandlerService msoResultHandlerService,
233 InProgressStatusService inProgressStatusService,
234 WatchChildrenJobsBL watchChildrenJobsBL,
235 JobsBrokerService jobsBrokerService,
236 JobAdapter jobAdapter) {
237 return new VolumeGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
238 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter);
242 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
243 public VfmoduleCommand VfmoduleCommand(
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 return new VfmoduleCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
253 inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
256 public AuditService auditService(RestMsoImplementation msoClient, AsyncInstantiationRepository asyncInstantiationRepository) {
257 return new AuditServiceImpl(msoClient, asyncInstantiationRepository);
261 public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService, FeatureManager featureManager) {
262 return new InProgressStatusService(asyncInstantiationBL, restMso, auditService, featureManager);
266 public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) {
267 return new MsoResultHandlerService(asyncInstantiationBL, auditService);
271 public CommandUtils commandUtils() {
272 return Mockito.mock(CommandUtils.class);
276 public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) {
277 return new WatchChildrenJobsBL(dataAccessService);