aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java
blob: ecec705a1200ba0660d525e496419f72f834ad01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*-
 * ============LICENSE_START=======================================================
 * VID
 * ================================================================================
 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.vid.config;

import org.hibernate.SessionFactory;
import org.mockito.Mockito;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.aai.util.SSLContextProvider;
import org.onap.vid.aai.util.ServletRequestHelper;
import org.onap.vid.aai.util.SystemPropertyHelper;
import org.onap.vid.dal.AsyncInstantiationRepository;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.command.ALaCarteServiceCommand;
import org.onap.vid.job.command.CommandUtils;
import org.onap.vid.job.command.InProgressStatusService;
import org.onap.vid.job.command.InstanceGroupCommand;
import org.onap.vid.job.command.InstanceGroupMemberCommand;
import org.onap.vid.job.command.JobCommandFactory;
import org.onap.vid.job.command.MacroServiceCommand;
import org.onap.vid.job.command.MsoRequestBuilder;
import org.onap.vid.job.command.MsoResultHandlerService;
import org.onap.vid.job.command.NetworkCommand;
import org.onap.vid.job.command.VfmoduleCommand;
import org.onap.vid.job.command.VnfCommand;
import org.onap.vid.job.command.VolumeGroupCommand;
import org.onap.vid.job.command.WatchChildrenJobsBL;
import org.onap.vid.job.impl.JobAdapterImpl;
import org.onap.vid.job.impl.JobWorker;
import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
import org.onap.vid.model.ModelUtil;
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AsyncInstantiationBusinessLogicImpl;
import org.onap.vid.services.AuditService;
import org.onap.vid.services.AuditServiceImpl;
import org.onap.vid.services.CloudOwnerService;
import org.onap.vid.services.InstantiationTemplatesService;
import org.onap.vid.services.VersionService;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.togglz.core.manager.FeatureManager;

@Configuration
public class JobCommandsConfigWithMockedMso {

    @Bean
    public RestMsoImplementation restMso() {
        return Mockito.mock(RestMsoImplementation.class);
    }

    @Bean
    public VersionService versionService() {
        return Mockito.mock(VersionService.class);
    }

    @Bean
    public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory, VersionService versionService) {
        return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0,versionService,featureManager());
    }

    @Bean
    public SSLContextProvider sslContextProvider() {
        return new SSLContextProvider();
    }

    @Bean
    public SystemPropertyHelper systemPropertyHelper() {
        return new SystemPropertyHelper();
    }

    @Bean
    public ServletRequestHelper servletRequestHelper() {
        return new ServletRequestHelper();
    }

    @Bean
    public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){
        return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
    }


    @Bean
    public JobAdapter jobAdapter(FeatureManager featureManager) {
        return new JobAdapterImpl(featureManager);
    }

    @Bean
    public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
        return new JobCommandFactory(applicationContext);
    }

    @Bean
    public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
        JobWorker jobWorker = new JobWorker();
        jobWorker.setJobsBrokerService(jobsBrokerService);
        jobWorker.setJobCommandFactory(jobCommandFactory);
        return jobWorker;
    }

    @Bean
    public FeatureManager featureManager() {
        return Mockito.mock(FeatureManager.class);
    }

    @Bean
    public MsoRequestBuilder msoRequestHandlerService(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
                                                      CloudOwnerService cloudOwnerService,
                                                      AaiClientInterface aaiClient,
                                                      FeatureManager featureManager) {
        return new MsoRequestBuilder(asyncInstantiationBusinessLogic, cloudOwnerService, aaiClient, featureManager);
    }
    @Bean
    public AsyncInstantiationRepository asyncInstantiationRepository(DataAccessService dataAccessService) {
        return new AsyncInstantiationRepository(dataAccessService);
    }

    @Bean
    public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(JobAdapter jobAdapter,
                                                                           JobsBrokerService jobsBrokerService,
                                                                           SessionFactory sessionFactory,
                                                                           AaiClientInterface aaiClient,
                                                                           FeatureManager featureManager,
                                                                           CloudOwnerService cloudOwnerService,
                                                                           AsyncInstantiationRepository asyncInstantiationRepository,
                                                                           AuditService auditService) {
        return new AsyncInstantiationBusinessLogicImpl(jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService, asyncInstantiationRepository, auditService);
    }

    @Bean
    public ModelUtil modelUtil() {return new ModelUtil();}

    @Bean
    public InstantiationTemplatesService instantiationTemplatesService(
        ModelUtil modelUtil,
        AsyncInstantiationRepository asyncInstantiationRepository,
        FeatureManager featureManager
        ) {
        return new InstantiationTemplatesService(modelUtil, asyncInstantiationRepository, featureManager);
    };


    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public ALaCarteServiceCommand aLaCarteServiceCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            JobsBrokerService jobsBrokerService,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            JobAdapter jobAdapter,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            RestMsoImplementation restMso,
            AuditService auditService,
            FeatureManager featureManager) {
        return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService, featureManager);
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public MacroServiceCommand macroServiceCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            JobsBrokerService jobsBrokerService,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            JobAdapter jobAdapter,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            RestMsoImplementation restMso,
            AuditService auditService,
            FeatureManager featureManager) {
        return new MacroServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService, featureManager);
    }


    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public NetworkCommand networkCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            RestMsoImplementation restMso,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            JobsBrokerService jobsBrokerService,
            JobAdapter jobAdapter,
            FeatureManager featureManager) {
        return new NetworkCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
                inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter, featureManager);
    }
    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public InstanceGroupCommand instanceGroupCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            RestMsoImplementation restMso,
            JobsBrokerService jobsBrokerService,
            JobAdapter jobAdapter,
            FeatureManager featureManager) {
        return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService,
            watchChildrenJobsBL, jobsBrokerService, jobAdapter, featureManager);
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public InstanceGroupMemberCommand instanceGroupMemberCommand (
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            RestMsoImplementation restMso,
            JobsBrokerService jobsBrokerService,
            JobAdapter jobAdapter,
            FeatureManager featureManager) {
        return new InstanceGroupMemberCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService,
                watchChildrenJobsBL, jobsBrokerService, jobAdapter, featureManager);
    }


    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public VnfCommand VnfCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            RestMsoImplementation restMso,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            JobsBrokerService jobsBrokerService,
            JobAdapter jobAdapter,
            FeatureManager featureManager) {
        return new VnfCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
                inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter,
                featureManager);
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public VolumeGroupCommand volumeGroupCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            RestMsoImplementation restMso,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            JobsBrokerService jobsBrokerService,
            JobAdapter jobAdapter,
            FeatureManager featureManager) {
        return new VolumeGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
                inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter, featureManager);
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public VfmoduleCommand VfmoduleCommand(
            AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
            RestMsoImplementation restMso,
            MsoRequestBuilder msoRequestBuilder,
            MsoResultHandlerService msoResultHandlerService,
            InProgressStatusService inProgressStatusService,
            WatchChildrenJobsBL watchChildrenJobsBL,
            JobsBrokerService jobsBrokerService,
            JobAdapter jobAdapter,
            FeatureManager featureManager) {
        return new VfmoduleCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
                inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter, featureManager);
    }
    @Bean
    public AuditService auditService(RestMsoImplementation msoClient, AsyncInstantiationRepository asyncInstantiationRepository) {
        return new AuditServiceImpl(msoClient, asyncInstantiationRepository);
    }

    @Bean
    public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService, FeatureManager featureManager) {
        return new InProgressStatusService(asyncInstantiationBL, restMso, auditService, featureManager);
    }

    @Bean
    public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) {
        return new MsoResultHandlerService(asyncInstantiationBL, auditService);
    }

    @Bean
    public CommandUtils commandUtils() {
        return Mockito.mock(CommandUtils.class);
    }

    @Bean
    public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) {
        return new WatchChildrenJobsBL(dataAccessService,featureManager());
    }

}