56ac28d2e1030d0c89192b316eff48b6ee907763
[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 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 Nokia. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.vid.config;
23
24 import org.hibernate.SessionFactory;
25 import org.mockito.Mockito;
26 import org.onap.portalsdk.core.service.DataAccessService;
27 import org.onap.vid.aai.AaiClientInterface;
28 import org.onap.vid.aai.util.HttpsAuthClient;
29 import org.onap.vid.aai.util.SSLContextProvider;
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.InProgressStatusCommand;
34 import org.onap.vid.job.command.JobCommandFactory;
35 import org.onap.vid.job.command.ServiceInstantiationCommand;
36 import org.onap.vid.job.impl.JobAdapterImpl;
37 import org.onap.vid.job.impl.JobWorker;
38 import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
39 import org.onap.vid.mso.RestMsoImplementation;
40 import org.onap.vid.services.AsyncInstantiationBusinessLogic;
41 import org.onap.vid.services.AsyncInstantiationBusinessLogicImpl;
42 import org.onap.vid.services.AuditService;
43 import org.onap.vid.services.AuditServiceImpl;
44 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
45 import org.springframework.context.ApplicationContext;
46 import org.springframework.context.annotation.Bean;
47 import org.springframework.context.annotation.Configuration;
48 import org.springframework.context.annotation.Scope;
49
50 @Configuration
51 public class JobCommandsConfigWithMockedMso {
52
53     @Bean
54     public RestMsoImplementation restMso() {
55         return Mockito.mock(RestMsoImplementation.class);
56     }
57
58     @Bean
59     public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
60         return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
61     }
62
63     @Bean
64     public HttpsAuthClient httpsAuthClientFactory(){
65         return new HttpsAuthClient("some random path", new SystemPropertyHelper(), new SSLContextProvider());
66     }
67
68     @Bean
69     public JobAdapter jobAdapter() {
70         return new JobAdapterImpl();
71     }
72
73     @Bean
74     public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
75         return new JobCommandFactory(applicationContext);
76     }
77
78     @Bean
79     public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
80         JobWorker jobWorker = new JobWorker();
81         jobWorker.setJobsBrokerService(jobsBrokerService);
82         jobWorker.setJobCommandFactory(jobCommandFactory);
83         return jobWorker;
84     }
85
86     @Bean
87     public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService,
88                                                                            JobAdapter jobAdapter,
89                                                                            JobsBrokerService jobsBrokerService,
90                                                                            SessionFactory sessionFactory,
91                                                                            AaiClientInterface aaiClient) {
92         return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient);
93     }
94
95     @Bean
96     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
97     public ServiceInstantiationCommand serviceInstantiationCommand() {
98         return new ServiceInstantiationCommand();
99     }
100
101     @Bean
102     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
103     public InProgressStatusCommand inProgressStatusCommand() {
104         return new InProgressStatusCommand();
105     }
106
107     @Bean
108     public AuditService auditService() {
109         return new AuditServiceImpl();
110     }
111
112 }