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.job.JobAdapter;
32 import org.onap.vid.job.JobsBrokerService;
33 import org.onap.vid.job.command.*;
34 import org.onap.vid.job.impl.JobAdapterImpl;
35 import org.onap.vid.job.impl.JobWorker;
36 import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
37 import org.onap.vid.mso.RestMsoImplementation;
38 import org.onap.vid.services.*;
39 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
40 import org.springframework.context.ApplicationContext;
41 import org.springframework.context.annotation.Bean;
42 import org.springframework.context.annotation.Configuration;
43 import org.springframework.context.annotation.Scope;
44 import org.togglz.core.manager.FeatureManager;
47 public class JobCommandsConfigWithMockedMso {
50 public RestMsoImplementation restMso() {
51 return Mockito.mock(RestMsoImplementation.class);
55 public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
56 return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
60 public SSLContextProvider sslContextProvider() {
61 return new SSLContextProvider();
65 public SystemPropertyHelper systemPropertyHelper() {
66 return new SystemPropertyHelper();
70 public ServletRequestHelper servletRequestHelper() {
71 return new ServletRequestHelper();
75 public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){
76 return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
80 public JobAdapter jobAdapter() {
81 return new JobAdapterImpl();
85 public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
86 return new JobCommandFactory(applicationContext);
90 public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
91 JobWorker jobWorker = new JobWorker();
92 jobWorker.setJobsBrokerService(jobsBrokerService);
93 jobWorker.setJobCommandFactory(jobCommandFactory);
98 public FeatureManager featureManager() {
99 return Mockito.mock(FeatureManager.class);
103 public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService,
104 JobAdapter jobAdapter,
105 JobsBrokerService jobsBrokerService,
106 SessionFactory sessionFactory,
107 AaiClientInterface aaiClient,
108 FeatureManager featureManager,
109 CloudOwnerService cloudOwnerService) {
110 return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService);
114 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
115 public MacroServiceInstantiationCommand serviceInstantiationCommand() {
116 return new MacroServiceInstantiationCommand();
120 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
121 public ServiceInProgressStatusCommand inProgressStatusCommand() {
122 return new ServiceInProgressStatusCommand();
126 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
127 public ALaCarteServiceInstantiationCommand aLaCarteServiceInstantiationCommand() {
128 return new ALaCarteServiceInstantiationCommand();
132 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
133 public ALaCarteServiceCommand aLaCarteServiceCommand(
134 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
135 JobsBrokerService jobsBrokerService,
136 MsoResultHandlerService msoResultHandlerService,
137 JobAdapter jobAdapter,
138 InProgressStatusService inProgressStatusService,
139 WatchChildrenJobsBL watchChildrenJobsBL,
140 RestMsoImplementation restMso) {
141 return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoResultHandlerService, jobAdapter, restMso);
145 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
146 public InstanceGroupCommand instanceGroupCommand(
147 AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
148 MsoResultHandlerService msoResultHandlerService, InProgressStatusService inProgressStatusService,
149 WatchChildrenJobsBL watchChildrenJobsBL,
150 RestMsoImplementation restMso) {
151 return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL);
155 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
156 public VnfInstantiationCommand vnfInstantiationCommand() {
157 return new VnfInstantiationCommand();
161 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
162 public VolumeGroupInstantiationCommand volumeGroupInstantiationCommand() {
163 return new VolumeGroupInstantiationCommand();
167 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
168 public WatchingCommandBaseModule watchingCommandBaseModule() {
169 return new WatchingCommandBaseModule();
173 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
174 public VolumeGroupInProgressStatusCommand volumeGroupInProgressStatusCommand() {
175 return new VolumeGroupInProgressStatusCommand();
179 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
180 public VfmoduleInstantiationCommand vfmoduleInstantiationCommand() {
181 return new VfmoduleInstantiationCommand();
185 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
186 public WatchingCommand watchingCommandCommand() {
187 return new WatchingCommand();
191 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
192 public ResourceInProgressStatusCommand resourceInProgressStatusCommand() {
193 return new ResourceInProgressStatusCommand();
197 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
198 public VnfInProgressStatusCommand vnfInProgressStatusCommand() {
199 return new VnfInProgressStatusCommand();
203 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
204 public InstanceGroupInstantiationCommand instanceGroupInstantiationCommand() {
205 return new InstanceGroupInstantiationCommand();
209 public AuditService auditService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation msoClient) {
210 return new AuditServiceImpl(asyncInstantiationBL, msoClient);
214 public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) {
215 return new InProgressStatusService(asyncInstantiationBL, restMso, auditService);
219 public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) {
220 return new MsoResultHandlerService(asyncInstantiationBL, auditService);
224 public CommandUtils commandUtils() {
225 return Mockito.mock(CommandUtils.class);
229 public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) {
230 return new WatchChildrenJobsBL(dataAccessService);