1fc46eeb9cfe6f21cf7fb212e73b14ff6b331ec0
[vid.git] / vid-app-common / src / test / java / org / onap / vid / config / JobCommandsConfigWithMockedMso.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.vid.config;
22
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;
45
46 @Configuration
47 public class JobCommandsConfigWithMockedMso {
48
49     @Bean
50     public RestMsoImplementation restMso() {
51         return Mockito.mock(RestMsoImplementation.class);
52     }
53
54     @Bean
55     public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
56         return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
57     }
58
59     @Bean
60     public SSLContextProvider sslContextProvider() {
61         return new SSLContextProvider();
62     }
63
64     @Bean
65     public SystemPropertyHelper systemPropertyHelper() {
66         return new SystemPropertyHelper();
67     }
68
69     @Bean
70     public ServletRequestHelper servletRequestHelper() {
71         return new ServletRequestHelper();
72     }
73
74     @Bean
75     public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){
76         return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
77     }
78
79     @Bean
80     public JobAdapter jobAdapter() {
81         return new JobAdapterImpl();
82     }
83
84     @Bean
85     public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
86         return new JobCommandFactory(applicationContext);
87     }
88
89     @Bean
90     public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
91         JobWorker jobWorker = new JobWorker();
92         jobWorker.setJobsBrokerService(jobsBrokerService);
93         jobWorker.setJobCommandFactory(jobCommandFactory);
94         return jobWorker;
95     }
96
97     @Bean
98     public FeatureManager featureManager() {
99         return Mockito.mock(FeatureManager.class);
100     }
101
102     @Bean
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);
111     }
112
113     @Bean
114     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
115     public MacroServiceInstantiationCommand serviceInstantiationCommand() {
116         return new MacroServiceInstantiationCommand();
117     }
118
119     @Bean
120     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
121     public ServiceInProgressStatusCommand inProgressStatusCommand() {
122         return new ServiceInProgressStatusCommand();
123     }
124
125     @Bean
126     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
127     public ALaCarteServiceInstantiationCommand aLaCarteServiceInstantiationCommand() {
128         return new ALaCarteServiceInstantiationCommand();
129     }
130
131     @Bean
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);
142     }
143
144     @Bean
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);
152     }
153
154     @Bean
155     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
156     public VnfInstantiationCommand vnfInstantiationCommand() {
157         return new VnfInstantiationCommand();
158     }
159
160     @Bean
161     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
162     public VolumeGroupInstantiationCommand volumeGroupInstantiationCommand() {
163         return new VolumeGroupInstantiationCommand();
164     }
165
166     @Bean
167     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
168     public WatchingCommandBaseModule watchingCommandBaseModule() {
169         return new WatchingCommandBaseModule();
170     }
171
172     @Bean
173     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
174     public VolumeGroupInProgressStatusCommand volumeGroupInProgressStatusCommand() {
175         return new VolumeGroupInProgressStatusCommand();
176     }
177
178     @Bean
179     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
180     public VfmoduleInstantiationCommand vfmoduleInstantiationCommand() {
181         return new VfmoduleInstantiationCommand();
182     }
183
184     @Bean
185     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
186     public WatchingCommand watchingCommandCommand() {
187         return new WatchingCommand();
188     }
189
190     @Bean
191     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
192     public ResourceInProgressStatusCommand resourceInProgressStatusCommand() {
193         return new ResourceInProgressStatusCommand();
194     }
195
196     @Bean
197     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
198     public VnfInProgressStatusCommand vnfInProgressStatusCommand() {
199         return new VnfInProgressStatusCommand();
200     }
201
202     @Bean
203     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
204     public InstanceGroupInstantiationCommand instanceGroupInstantiationCommand() {
205         return new InstanceGroupInstantiationCommand();
206     }
207
208     @Bean
209     public AuditService auditService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation msoClient) {
210         return new AuditServiceImpl(asyncInstantiationBL, msoClient);
211     }
212
213     @Bean
214     public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) {
215         return new InProgressStatusService(asyncInstantiationBL, restMso, auditService);
216     }
217
218     @Bean
219     public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) {
220         return new MsoResultHandlerService(asyncInstantiationBL, auditService);
221     }
222
223     @Bean
224     public CommandUtils commandUtils() {
225         return Mockito.mock(CommandUtils.class);
226     }
227
228     @Bean
229     public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) {
230         return new WatchChildrenJobsBL(dataAccessService);
231     }
232
233 }